I´m having a stupid problem with java.util.Date
.
I have this line of code, but I don´t understand why this date is unparseable with this format.
public class TestTime {
public static void main(String[] args) {
final String DATE_FORMAT = "EEE MMM dd HH:mm:ss zzz yyyy";
String date = "Sat Dec 31 10:00:00 CET 2011";
SimpleDateFormat dFormat = new SimpleDateFormat(DATE_FORMAT);
Date lDate = null;
try {
lDate = dFormat.parse(date);
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
If your system uses a locale other than English you need to use this constructor:
SimpleDateFormat(DATE_FORMAT,Locale.ENGLISH);
If this is not the problem, you should format a date using the same formatter and compare the output to your input string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With