Java Date时间比较大小
String DateStr1 = "2013-10-01 10:10:10";
String DateStr2 = "2013-10-02 11:11:11";
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date dateTime1 = dateFormat.parse(DateStr1);
Date dateTime2 = dateFormat.parse(DateStr2);
System.out.println(dateTime1.compareTo(dateTime2));
注:
如果dateTime1大于dateTime2,则返回1;
如果dateTime1等于dateTime2,则返回0;
如果dateTime1小于dateTime2,则返回-1;