Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 2 个字符串格式的日期,例如DD/MM/YYYY. 现在我必须写条件 if date1is before date2。我怎样才能做到这一点?请帮我。
DD/MM/YYYY
date1
date2
尝试这个:
SimpleDateFormat curFormater = new SimpleDateFormat("dd/MM/yyyy"); Date date1 = curFormater.parse(date1Str); Date date2 = curFormater.parse(date2Str); if (date1.before(date2)) { }