1

I'm using a Java mail client to read my emails. The Date field contained in the message reads as:

Sat Dec 20 12:25:54 CET 2014

I wonder if there is a safe way to convert it in Java to a language independent format such as:

dd/MM/YYYY HH:MM

Thanks

user2824073
  • 2,407
  • 10
  • 39
  • 73

1 Answers1

1

You can use SimpleDateFormat To parse String representing Sat Dec 20 12:25:54 CET 2014 E.g.

SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
Date d = sdf.parse(dateString);

If you want date to be converted into String dd/MM/YYYY HH:MM then specify this format to SimpleDateFormat like this

SimpleDateFormat sdf2 = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.ENGLISH);
String s = sdf2.format(new Date());
sol4me
  • 15,233
  • 5
  • 34
  • 34