Java SQL Timestamp convert Instant

Description

Java SQL Timestamp convert Instant

import java.sql.Timestamp;
import java.time.Instant;


public class Main {
  public static void main(String[] args) {
     /*from   ww w.  j  a v  a 2s  .c om*/
     Timestamp timestamp = Timestamp.valueOf("2020-02-24 12:42:42.11");
     System.out.println("timestamp:"+timestamp);
     
     Instant ins = timestamp.toInstant();
     System.out.println("ins:"+ins);
     
  }
}



PreviousNext

Related