Java API Tutorial - Java Timestamp.setTime(long time)








Syntax

Timestamp.setTime(long time) has the following syntax.

public void setTime(long time)

Example

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

import java.util.Date;
//from   ww w .j  a v  a  2 s  .  c  om
public class Main {
  public static void main(String[] args) {
    java.sql.Timestamp ts1 = java.sql.Timestamp.valueOf("2012-04-06 09:01:10");
    
    ts1.setTime(new Date().getTime());
    System.out.println(ts1);

  }
}

The code above generates the following result.