
Patrick B. answered 05/24/19
Math and computer tutor/teacher
does it work? have you tested it?
you have declared it in your format string dd-MM-yyyy as the day, then month, then year.
You can parse this string and then compare the integers:
dateBuff = std.format(c1.getTime());
String [] tokens = parse(dateBuff,"-"); /* tokens[0] contains the day, tokens[1] contains the month, tokens[2] contains the year */
int day1 = Integer.parseInt(tokens[0]);
int month1 = Integer.parseInt(tokens[1]);
int year1 = Integer.parseInt(tokens[2]);
// processes the second date in the same way, then compare
I would suggest declaring this method inside of an interface CompareDate.
First create an interface Sortable containing a method called Compare( Object, Object);
Then class CompareDate implements Sortable, which typecasts the Object to date and compares