Hi there,
I have the following problem with converting a
String to a Date.
While my code segment worked just fine with jdk 1.4.2 I have problems migrating this code to jdk 5.0.
Here is the code which worked just fine with jdk 1.4.2:
private static Date convertStringToDate(String text)
throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
simpleDateFormat.setLenient(false);
Date date = simpleDateFormat.parse(text);
return date;
} // StringToDate
Passing this function a text = "2006-11-20T15:16:24.000+0000" resulted in no exceptions (my timezone is "Europe/Berlin").
Running this function under JDK 5.0 throws the following exception:
java.text.ParseException: Unparseable date: "2006-11-20T15:16:24.000+0000"
I believe that the cause of the problem are the last 5 digits of the text - string in combination with the current timezone. That seems to have changed since jdk 1.4.2.
My problem now is that I just get a string like the one above and want to convert it to a date without setting a prober timezone (just like running this code under jdk 1.4.2). How can I accopmplish this under jdk 1.5?
Thanks in advance for any answers...
[ August 09, 2008: Message edited by: Karl Weber ]
[ August 09, 2008: Message edited by: Karl Weber ]
[ August 09, 2008: Message edited by: Karl Weber ]