user993444
user993444

Reputation: 53

Date comparison in Android application

I have 2 dates in string format like DD/MM/YYYY. Now I have to write the condition if date1 is before date2. How can I do this? Please help me.

Upvotes: 3

Views: 4978

Answers (1)

Marco
Marco

Reputation: 57573

Try this:

SimpleDateFormat curFormater = new SimpleDateFormat("dd/MM/yyyy"); 
Date date1 = curFormater.parse(date1Str); 
Date date2 = curFormater.parse(date2Str); 
if (date1.before(date2)) 
{
}

Upvotes: 9

Related Questions