Here you can find the source of compareDate(String DATE1, String DATE2)
Parameter | Description |
---|
Parameter | Description |
---|
public static boolean compareDate(String DATE1, String DATE2)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static boolean compareDate(String DATE1, String DATE2) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm"); boolean compareFlag = false; try {//from w ww. j a v a 2s. c o m Date dt1 = df.parse(DATE1); Date dt2 = df.parse(DATE2); if (dt1.getTime() > dt2.getTime()) { compareFlag = true; } else if (dt1.getTime() < dt2.getTime()) { compareFlag = false; } else { compareFlag = false; } } catch (Exception exception) { exception.printStackTrace(); } return compareFlag; } }