进入要比较从库中取出的时间,期初使用比较date.getTime()的值,但是当时间的年月日都相同时,时分秒较早的getTime()值比时分秒较晚的getTime()的值要大,至今笔者还不知这是为什么?
但是找到了一个比较好的比较时间的方法如下:
Calendar c1=Calendar.getInstance();
Calendar c2=Calendar.getInstance();
DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
c1.setTime(df.parse("2015/02/12 12:45:56"))
c2.setTime(df.parse("2015/03/12 12:45:56"))
int result =c1.compare(c2);