Java Timestamp Create toTimestampFromLong(long millis)

Here you can find the source of toTimestampFromLong(long millis)

Description

Returns the Timestamp corresponding to millis, which denotes the point in time that many milliseconds since the epoch; returns null if millis is negative.

License

Open Source License

Declaration

public static Timestamp toTimestampFromLong(long millis) 

Method Source Code


//package com.java2s;

import java.sql.Timestamp;

public class Main {
    /**/*from  w ww .  jav  a 2s.com*/
     * Returns the Timestamp corresponding to <code>millis</code>, which denotes
     * the point in time that many milliseconds since the epoch; returns <code>null</code>
     * if <code>millis</code> is negative.
     */
    public static Timestamp toTimestampFromLong(long millis) {
        if (millis < 0) {
            return null;
        }
        return new Timestamp(millis);
    }
}

Related

  1. toTimestamp2(long seconds, int fraction, int width)
  2. toTimestamp2(long seconds, int nanos)
  3. toTimestamp2(long value, int nanos, int meta)
  4. toTimestampByHour(Date date, int hour)
  5. toTimestampFromGMT(int yy, int mm, int dd, int hh, int mi, int ss)
  6. toTimestampFromTime(String time)