-
December 21st, 2011, 03:45 AM
#1
String to Date conversion issue
Hi,
I am trying to convert the string date to actual date using SimpleDateFormat class. But it seems the SimpleDateFormat class is returning the invalid value for the date object. It is increasing the minute value by 1. I am not sure if it's an actual issue with SimpleDateFormat class or my way of conversion is wrong. Any help ?
The code :
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.ms'Z'");
Date date = dateFormat.parse("2011-12-20T15:08:14.917Z");
System.out.println("Date: " + date);
It is displaying "Tue Dec 20 15:09:17 IST 2011" instead of "Tue Dec 20 15:08:14 IST 2011".
Thanks in advance.
-
December 21st, 2011, 05:49 AM
#2
Re: String to Date conversion issue
The problem is with your format string, it should be:
Code:
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'");
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|