Java LocalDateTime convert to SQL Timestamp

Description

Java LocalDateTime convert to SQL Timestamp

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 a  v a2 s .c o m
     Timestamp timestamp = Timestamp.valueOf(localDateTime);
     System.out.println("timestamp:"+timestamp);
     
  }
}



PreviousNext

Related