Comparing two timestamps
问题 I want to compare the following two timestamps. It should return true but due to single digit and double digit milliseconds in the two timestamps, it is returning false . What can I do to make it return true public static void main(String[] args) throws ParseException { String d1 = "2011-12-31 07:11:01.5"; String d2 = "2011-12-31 07:11:01.50"; SimpleDateFormat s1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); SimpleDateFormat s2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS"); Date dateOne