I have the following method to convert String to date with millisecond granularity
public Date convertTime(String time) {
SimpleDateFormat parser = new SimpleDateFormat("HH:mm:ss.S");
try {
return parser.parse(time);
}
catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
Date d1 = lib.convertTime("10:30:53.39");
Date d2 = lib.convertTime("10:30:53.40");
System.out.println(d1.after(d2));
returns false as expected
However the following
Date d1 = lib.convertTime("10:30:53.39");
Date d2 = lib.convertTime("10:30:53.4");
System.out.println(d1.after(d2));
Which I thought would have been the same returns true. What am I doing wrong?