I have the following value: 2018-01-16-18.56.57.300000
It is passed to the method parameter: "value".
private Timestamp getPossibleTimestampI(String value) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh.mm.ss.SSS");
Date parsedDate;
Timestamp timestamp=null;
try {
parsedDate = dateFormat.parse(value);
timestamp = new java.sql.Timestamp(parsedDate.getTime());
} catch (ParseException e1) {
e1.printStackTrace();
}
return timestamp;
}
I am getting a Timestamp object with the value of 2018-01-16 19:01:57.0, about 5 minutes more compared to the original string value.
Why is this happening, and how can I correct my conversion?
In Time 2018-01-16-18.56.57.300000, Your 300000 milliseconds are being converted to minutes
which is 300000/60000 = 5 minutes