Java Timestamp(long time) Constructor

Syntax

Timestamp(long time) constructor from Timestamp has the following syntax.

public Timestamp(long time)

Example

In the following code shows how to use Timestamp.Timestamp(long time) constructor.


public class Main {
  public static void main(String[] args) {
    java.util.Date today = new java.util.Date();
    java.sql.Timestamp ts1 = new java.sql.Timestamp(today.getTime());
/*from w  ww .ja v  a  2  s.  c  o m*/
    long tsTime1 = ts1.getTime();
    
    System.out.println(tsTime1);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.sql »




DatabaseMetaData
ParameterMetaData
PreparedStatement
ResultSet
Timestamp