Line analysis to date

I lost a little here, I think I am doing everything fine and it still does not work (PaseException

    String time = "Fri Apr 15 14:29:57 IDT 2011";
    SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy");
    sdf.parse(time);

Help get a high rating!

+2
source share
3 answers
String time = "Fri Apr 15 14:29:57 IDT 2011";
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy");
System.out.println(sdf.parse(time));

Works great for me.!

Perhaps you can try with

 SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy",Locale.ENGLISH);
+6
source

Your default locale is not compatible with this date pattern.

Try:

SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy", Locale.ENGLISH);

(I confirmed it as working)

+3
source

add locale as the second constructor parameter:

    String time = "Fri Apr 15 14:29:57 IDT 2011";
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy", Locale.ENGLISH);
System.out.println(sdf.parse(time));
+1
source

All Articles