Hi, Thanks for the comments, I wish you could do the test of the method that I included with the test data and validate the problem that I am detecting.
El Friday, June 25, 2021 a la(s) 4:28:11 PM UTC-5, [email protected] escribió: > The problem with SimpleDateFormat is that it can't cope with a lot of the > junk that passes for "date" out there > in the real world. I gave up and wrote my own parser, which I have > extended to handle the dates that I actually > encounter. > > > On Thursday, June 24, 2021 at 8:30:41 PM UTC-7 Shai Almog wrote: > >> Hi, >> I don't understand the problem. We have SimpleDateFormat in Codename One >> it's just under the codename one packages in the import. >> >> On Thursday, June 24, 2021 at 11:35:56 AM UTC+3 [email protected] wrote: >> >>> Hi, >>> >>> I created a new method in CodenameOne, but it is sending me an error. >>> To test: >>> fecha = new Date (). ToString () >>> tipo = "T" >>> >>> public static String cambiaFormatoFecha(String fecha, String tipo) { >>> String formato = tipo.equals("F") ? "yyyy-MM-dd" : >>> tipo.equals("H") ? "hh:mm:ss" : tipo.equals("T") ? "yyyy-MM-dd hh:mm:ss" : >>> ""; >>> SimpleDateFormat formaFecha = new SimpleDateFormat(formato); >>> Date d = null; >>> try { >>> d = formaFecha.parse(fecha); >>> } catch (ParseException ex) { >>> Dialog.show("Error", "Error formato de fecha", "Continuar", >>> null); >>> } >>> return formaFecha.format(d); >>> } >>> >>> El Wednesday, June 23, 2021 a la(s) 11:17:52 PM UTC-5, [email protected] >>> escribió: >>> >>>> Hi, >>>> >>>> In java you could have the following method: >>>> >>>> public static Date ParseFecha(String fecha) { >>>> SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); >>>> Date fechaDate = null; >>>> try { >>>> fechaDate = formato.parse(fecha); >>>> } >>>> catch (ParseException ex) { >>>> System.out.println(ex); >>>> } >>>> return fechaDate; >>>> } >>>> >>>> How can I get this to work in CodenameOne? >>>> >>> -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/ad651366-d4af-4810-8459-2fb290e19d40n%40googlegroups.com.
