Click here to watch on Youtube:
https://www.youtube.com/watch?v=NqUUxDyjXuc&list=UUhwKlOVR041tngjerWxVccw
TimestampDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/TimestampDemo_getTime_nanos.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/TimestampDemo_getTime_nanos
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/5bada39e8532ab4b75aaa28b80cdcee21bf19ab7/BasicJava_2018/TimestampDemo_getTime_nanos/?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=NqUUxDyjXuc&list=UUhwKlOVR041tngjerWxVccw
TimestampDemo.java
import java.sql.Timestamp;
public class TimestampDemo
{
public static void main(String[] args)
{
long millis = System.currentTimeMillis();
Timestamp timestamp = new Timestamp(millis);
System.out.println(timestamp);
/*
* Returns:the number of milliseconds since January 1, 1970,
* 00:00:00 GMT represented by this date.
*/
long milliseconds = timestamp.getTime();
System.out.println("milliseconds = " + milliseconds);
/*
* Gets this Timestamp object's nanos value.
*/
long nanoseconds = timestamp.getNanos();
System.out.println("nanoseconds = " + nanoseconds);
}
}
public class TimestampDemo
{
public static void main(String[] args)
{
long millis = System.currentTimeMillis();
Timestamp timestamp = new Timestamp(millis);
System.out.println(timestamp);
/*
* Returns:the number of milliseconds since January 1, 1970,
* 00:00:00 GMT represented by this date.
*/
long milliseconds = timestamp.getTime();
System.out.println("milliseconds = " + milliseconds);
/*
* Gets this Timestamp object's nanos value.
*/
long nanoseconds = timestamp.getNanos();
System.out.println("nanoseconds = " + nanoseconds);
}
}
Output
2018-11-09 09:51:20.999
milliseconds = 1541737280999
nanoseconds = 999000000
milliseconds = 1541737280999
nanoseconds = 999000000
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/TimestampDemo_getTime_nanos.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/TimestampDemo_getTime_nanos
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/5bada39e8532ab4b75aaa28b80cdcee21bf19ab7/BasicJava_2018/TimestampDemo_getTime_nanos/?at=master
See also:
 


 
No comments:
Post a Comment