posted 15 years ago
Hi,
I am trying to compare two dates in my program, where the current date is being compared with the selected date by the user from the calender. The selected date should not be more than 90 days from the current date. The function which i have defined gives correct result if the condition contains less than 68 days comparison, means instead of 90 days if you put 68 or less than 68 then the function gives the correct result but Once you give more than 68 days comparison the result I am getting is wrong. I don't understand where is the problem. Does any one have any idea what is wrong with this?
Here is the code I am using.
public boolean test1(){
long date = getCurrentDate();
return getStartDate() != null && getStartDate().getTime() > date + MILLISECONDS_IN_DAY * DAYS_THREE_MONTHS;
}
getCurrentDate(){
Calendar cal = new GregorianCalendar();
cal.setTime(new Date());
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTimeInMillis();
}
Thanks,
[ August 27, 2008: Message edited by: Bear Bibeault ]