opike
asked on
Compare just time portion of calendar and date objects
In my code I have a date and a calendar object and I want to compare just the time portion. I'm thinking of doing something like this
public myfunc(Calendar cal1, Date date1)
{
Calendar cal2 = (Calendar)cal1.clone();
cal2.setTime(date1);
if (cal2.after(cal1)
<more code here...>
}
But I'm having trouble with the setTime() function since it also assigns the date info as well. So I need a setTime() that will only set the time.
public myfunc(Calendar cal1, Date date1)
{
Calendar cal2 = (Calendar)cal1.clone();
cal2.setTime(date1);
if (cal2.after(cal1)
<more code here...>
}
But I'm having trouble with the setTime() function since it also assigns the date info as well. So I need a setTime() that will only set the time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER