Pergunta

I try to parse format date Fri Mar 30 00:00:00 CET 14 to dd/mm/yyyy

this is my code

   SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
   System.out.println(formatter.parse(date_retour.toString()));

error java.text.ParseException: Unparseable date: "Fri Mar 30 00:00:00 CET 14"

help please

it is okay now

    try {
        SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z", Locale.ENGLISH);  
        SimpleDateFormat formatter2 = new SimpleDateFormat("dd-MM-yyyy");  
        Date date;
        date = formatter.parse(date_retour.toString());
        donnees [i][9]  =formatter2.format(date);
    } catch (ParseException ex) {
        Logger.getLogger(operation2.class.getName()).log(Level.SEVERE, null, ex);
    }
Foi útil?

Solução

You need to match the date format pattern with the input String

SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z", Locale.ENGLISH); 
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top