SimpleDateFormat problems. I'm perplexed...
Dear all!
I'm having trouble with the SimpleDateFormat class (jdk1.5.0_04). When set to "lenient" it returns the wrong date. When lenient is set false(i.e. strict) it throws an exception. Pls have a look at my code:
publicstaticvoid main(String[] args){
try{
DateFormat formatter =new SimpleDateFormat("yyyy.MM.dd HH:mm");
formatter.setLenient(false);
Date date = (Date)formatter.parse("2006.03.26 02:15");
System.out.println(date);
}catch (ParseException e){
e.printStackTrace();
}
}
The above will throw a ParseException telling me that the date "2006.03.26 02:15" is unparseable.
When I set lenient to "true" it returns "Sun Mar 26 03:15:00 CEST 2006". The time is set to "03:15" which is clearly wrong. This seems to be a problem when the time portion is 02 (for other times it works!!)
What am I missing?
Any help is appreciated.
Best regards!

