I can't seem to see the problem with the example code below. For some reason seems to be ignoring the year and saying the dates are the same, as can be seen in the output below. I must be missing something simple.
01/28/2006
01/16/2007
Tue Apr 01 00:00:00 PDT 2008
Tue Apr 01 00:00:00 PDT 2008
done
import java.util.*;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
class ExampleProgram {
public static void main(String[] args){
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
String d1String = "01/28/2006";
String d2String = "01/16/2007";
System.out.println(d1String);
System.out.println(d2String);
Date d1=null;
try {
d1 = df.parse(d1String);
} catch (ParseException e) {
System.out.println(e.getMessage());
}
Date d2=null;
try {
d2 = df.parse(d2String);
} catch (ParseException e) {
System.out.println(e.getMessage());
}
System.out.println(d1);
System.out.println(d2);
System.out.println("done");
}
}