Hi i am creating instance of Calendar Using:
Calendar calendarDate=Calendar.getInstance();
calendarDate.set(2012, 6, 1,0,0,0);
Date date1=calendar.getTime();
After that i create instance of java.util.date using:
Date date2=new Date(2012 - 1900,7-1, 01);
Now when i am trying to compare dates using following code:
System.out.println(date2.compareTo(date1));
System.out.println(date1.compareTo(date2));
it prints -1 and 1 instead of 0(zero).
Can any one help me to find what’s goes wrong ?
Try to clear the value of calendar before set a new one. This will solve your problem.
Test for it: