Java Timestamp Create toTimestamp(long ts)

Here you can find the source of toTimestamp(long ts)

Description

to Timestamp

License

Apache License

Declaration

public static Timestamp toTimestamp(long ts) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Timestamp;

public class Main {
    public static Timestamp toTimestamp(long ts) {
        if (ts == 0) {
            //            return new Timestamp(0);
            return null;
        }/*from   w w w  .j  a  va2 s . co m*/
        if (String.valueOf(ts).length() == 10) {
            ts = ts * 1000;
        }
        return new Timestamp(ts);
    }
}

Related

  1. toTimestamp(final Instant instant)
  2. toTimestamp(final int year, final int month, final int dayOfMonth, final int hour, final int minute, final int second, final int millsecond)
  3. toTimestamp(final java.sql.Date date)
  4. toTimestamp(final String pValue)
  5. toTimestamp(java.sql.Date date)
  6. toTimestamp(long value)
  7. toTimestamp(Object dateobj)
  8. toTimestamp(Object objInParam)
  9. toTimestamp(String _sDate)