Basically I'm trying to convert string data to Timestamp format. When I converted data to timestamp format, SimpleDateFormat added three minutes. Because milisecond data equals 3 minute.But I want to preserve milisecond data on timestamp value.
Code:
public Double TimestampTest(String Timestamp ){
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date parsedDate = null;
try {
parsedDate = dateFormat.parse(Timestamp);
} catch (ParseException e1) {
e1.printStackTrace();
}
Timestamp timestamp = new java.sql.Timestamp(parsedDate.getTime());
...
}
Timestamp value
2002-04-17 23:45:58.983
For test case
System.out.println(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse("2015-04-22T19:54:11.219983Z"));
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS'Z'").parse("2015-04-22 19:54:11.219983Z"));
Results are same for both of them
Wed Apr 22 19:57:50 EEST 2015
Wed Apr 22 19:57:50 EEST 2015
Because
219 983 milliseconds = 3.66638333 minutes
To sum up I want to preserve ms data .Is there any way to do it ?