I've found out a very useful library which is the SimpleDateFormat for the formatting of date. That is not the problem. The compareTo method serve my purpose of comparing the date but my problem is that the compareTo doesn't show the difference between then
For example the code below:
String date1 = "Apr 2010";
String date2 = "Jan 2009";
SimpleDateFormat format = new SimpleDateFormat("MMM yy");
Date d1 = null;
Date d2 = null;
d1 = format.parse(date1);
d2 = format.parse(date2);
int test1 = d1.compareTo(d2);
System.out.println(test1);
The output of the above gives me -9. May I know how does the method compareTo calculates it?
What I want is that to find the difference between those months and years. Thank you very much.