Java Timestamp Memo

timestamp的构造函数,把微妙作为纳秒存储,
所以 Java.util.date.comepareTo(Timestamp) 结果肯定是1
另外,​Timestamp.equal(object) 如果参数不是Timestamp,肯定返回false。
Timestamp's nanos value is NOT the number of nanoseconds - it's ananosecond-resolution number of millis (i.e. fractional seconds).As such, in the Timestamp constructor, it is setting the time onthe super to be without milliseconds. Therefore, the Timestamp willalways have a lower value for the member fastTime (used in Date'scompareTo()) than the corresponding Date (unless, of course, it hasno fractional seconds).
 

   publicTimestamp(long time) {
       super((time/1000)*1000);
       nanos = (int)((time00) * 1000000);
       if (nanos < 0) {
           nanos = 1000000000 + nanos;
           super.setTime(((time/1000)-1)*1000);
       }
    }
posted on 2017-02-14 10:57  sdfczyx  阅读(220)  评论(0编辑  收藏  举报