Java SQL Timestamp create from LocalDateTime

Description

Java SQL Timestamp create from LocalDateTime

import java.sql.Timestamp;
import java.time.LocalDateTime;



public class Main {
  public static void main(String[] args) {
     LocalDateTime localDateTime = LocalDateTime.now();
     System.out.println("local date time:"+localDateTime);
     //from  w w  w .  j  ava 2 s.  com
     Timestamp timestamp = Timestamp.valueOf(localDateTime);
     System.out.println("timestamp:"+timestamp);
     
  }
}



PreviousNext

Related