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/0cfc7b40-11ac-4c35-8803-c119d7c2b1e3n%40googlegroups.com.

Reply via email to