简体   繁体   中英

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.

Try this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM