jdk源代码中有关日期比较

来源:互联网 发布:windows关机日志 编辑:程序博客网 时间:2024/05/08 13:40

public int compareTo(Date anotherDate) { 
       long thisTime = getMillisOf(this); 
       long anotherTime = getMillisOf(anotherDate); 
       return (thisTime<anotherTime ? -1 : (thisTime==anotherTime ? 0 : 1)); 
       }
   一直在用自己实现的比较日期,今天看看,jdk源代码中的实现也是蛮不错的嘛。自己实现的是传入两个字符串形式的日期,yyyy-MM-dd形式的。

原创粉丝点击