Click here to watch on Youtube: 
https://www.youtube.com/watch?v=zkFdaAe9RHw&list=UUhwKlOVR041tngjerWxVccw
TimestampDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/TimestampDemo_toInstant.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/TimestampDemo_toInstant
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/5bada39e8532ab4b75aaa28b80cdcee21bf19ab7/BasicJava_2018/TimestampDemo_toInstant/?at=master
See also:
All JavaEE Videos Playlist 
All JavaEE Videos 
All JAVA EE Links 
Spring Tutorial 
Servlets Tutorial 
All Design Patterns Links 
JDBC Tutorial 
Java Collection Framework Tutorial 
JAVA Tutorial 
Kids Tutorial 
Cooking Tutorial 
https://www.youtube.com/watch?v=zkFdaAe9RHw&list=UUhwKlOVR041tngjerWxVccw
TimestampDemo.java
import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDateTime;
public class TimestampDemo
{
public static void main(String[] args)
{
long millis = System.currentTimeMillis();
Timestamp timestamp = new Timestamp(millis);
System.out.println("timestamp = "+timestamp);
/*
* Converts this Timestamp object to an Instant.
*/
Instant instant = timestamp.toInstant();
System.out.println("instant = "+instant);
/*
* Converts this Timestamp object to a LocalDateTime.
*/
LocalDateTime localDateTime = timestamp.toLocalDateTime();
System.out.println("localDateTime = "+localDateTime);
}
}
import java.time.Instant;
import java.time.LocalDateTime;
public class TimestampDemo
{
public static void main(String[] args)
{
long millis = System.currentTimeMillis();
Timestamp timestamp = new Timestamp(millis);
System.out.println("timestamp = "+timestamp);
/*
* Converts this Timestamp object to an Instant.
*/
Instant instant = timestamp.toInstant();
System.out.println("instant = "+instant);
/*
* Converts this Timestamp object to a LocalDateTime.
*/
LocalDateTime localDateTime = timestamp.toLocalDateTime();
System.out.println("localDateTime = "+localDateTime);
}
}
Output
timestamp = 2018-11-12 10:14:13.501
instant = 2018-11-12T04:44:13.501Z
localDateTime = 2018-11-12T10:14:13.501
instant = 2018-11-12T04:44:13.501Z
localDateTime = 2018-11-12T10:14:13.501
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/TimestampDemo_toInstant.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/TimestampDemo_toInstant
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/5bada39e8532ab4b75aaa28b80cdcee21bf19ab7/BasicJava_2018/TimestampDemo_toInstant/?at=master
See also:
 


 
No comments:
Post a Comment