I have a requirement to parse the date into milliseconds. Here is how I am doing it.
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
public void setTime(String date) {
try {
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
this.time = sdf.parse(date).getTime();
} catch (ParseException e) {
e.printStackTrace();
}
Here is the problem in my server.
For example, for the given input date "2015-06-20T01:57:13Z", I get output value as 1592618233000 ms, however, the expected value should be 1434765433000.
Analyzing the issue I found that difference of 157852800000 ms which when converted gives to "Thu Jan 01 1975 05:30:00 GMT+0530 (IST)" Date.
I see that 157852800000 ms is getting added to few of the dates in my server. There is no code issue here. I am using the code as shown above. When I run the same in my local machine it is working absolutely fine. Also, this scenario in my server do not occur all the times.
Please advise on this.
Aucun commentaire:
Enregistrer un commentaire