Hi,
I've got a question about SimpleDateFormat class and the java.util.Date's compareto method:
I'm constructing a Date object, then I format, finally I parse the formatted string and compare to the original date.
DateFormat df = new SimpleDateFormat("yyyy.MMMdd hh:mm:ss SSS");
Date originalDate = new Date();
String s = df.format(originalDate);
Date parsedDate = df.parse(s);
System.out.println("Original date: " + originalDate);
System.out.println("Formatted date: " + s);
System.out.println("originalDate compareTo parsedDate: " + originalDate.compareTo(parsedDate));
The result:
Original date: Mon Jan 25 15:43:23 CET 2010 Formatted date: 2010.jan.25 03:43:23 868 originalDate compareTo parsedDate: 1
Why I am getting always "1"? Why the original date grater than the parsed date?