java.sql.Timestamp

2022-04-28  本文已影响0人  等你足够强了再说吧
/**
 * Constructs a <code>Timestamp</code> object
 * using a milliseconds time value. The
 * integral seconds are stored in the underlying date value; the
 * fractional seconds are stored in the <code>nanos</code> field of
 * the <code>Timestamp</code> object.
 *
 * @param time milliseconds since January 1, 1970, 00:00:00 GMT.
 *        A negative number is the number of milliseconds before
 *         January 1, 1970, 00:00:00 GMT.
 * @see java.util.Calendar
 */
public Timestamp(long time) {
    super((time/1000)*1000);
    nanos = (int)((time%1000) * 1000000);
    if (nanos < 0) {
        nanos = 1000000000 + nanos;
        super.setTime(((time/1000)-1)*1000);
    }
}
上一篇下一篇

猜你喜欢

热点阅读