• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Stuck while comparing dates

Hi, My self Livin.
I'm a Android Developer, working on a reminder application. I have got a scenario to compare two date objects but it should not take the time, just the date.
I even tried with calendar objects, but no let..
Can u guys please help to resolve my issue...?
 
Welcome to the forums :)

Looks like codesplice has got a helpful link there for you. Hope it helps, and if you have any other questions feel free to ask.
 
I have gone through the Stack Overflow link, and got something like this.
Will this be useful ..?

// PREVIOUS DATE
Date dueDate = new Date(previuosDate);
Calendar caldueDate = Calendar.getInstance();
caldueDate.setTime(dueDate);

// CURRENT SYSTEM DATE
Date current_date = new Date();
Calendar currentDate = Calendar.getInstance();
currentDate.setTime(current_date);

// SET THE TIME PART TO 1 TO CONSIDER ONLY DATE
caldueDate.set(Calendar.HOUR, 1);
caldueDate.set(Calendar.MINUTE, 0);
caldueDate.set(Calendar.SECOND, 0);
caldueDate.set(Calendar.MILLISECOND, 0);

currentDate.set(Calendar.SECOND, 0);
currentDate.set(Calendar.MINUTE, 0);
currentDate.set(Calendar.HOUR, 1);
currentDate.set(Calendar.MILLISECOND, 0);

if (caldueDate.before(currentDate)) {
//My code
}
 
Back
Top Bottom