Click here to watch on Youtube:
https://www.youtube.com/watch?v=gbA_BDVwo3w&list=UUhwKlOVR041tngjerWxVccw
TimestampDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/TimestampDemo_Create.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/TimestampDemo_Create
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/5bada39e8532ab4b75aaa28b80cdcee21bf19ab7/BasicJava_2018/TimestampDemo_Create/?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=gbA_BDVwo3w&list=UUhwKlOVR041tngjerWxVccw
TimestampDemo.java
import java.sql.Timestamp;
import java.util.Date;
public class TimestampDemo
{
public static void main(String[] args)
{
// method 1
long millis = System.currentTimeMillis();
Timestamp timestamp = new Timestamp(millis);
System.out.println(timestamp);
// method 2 - via Date
Date date = new Date();
millis = date.getTime();
timestamp = new Timestamp(millis);
System.out.println(timestamp);
}
}
import java.util.Date;
public class TimestampDemo
{
public static void main(String[] args)
{
// method 1
long millis = System.currentTimeMillis();
Timestamp timestamp = new Timestamp(millis);
System.out.println(timestamp);
// method 2 - via Date
Date date = new Date();
millis = date.getTime();
timestamp = new Timestamp(millis);
System.out.println(timestamp);
}
}
Output
2018-11-07 09:26:20.266
2018-11-07 09:26:39.52
2018-11-07 09:26:39.52
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/TimestampDemo_Create.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/TimestampDemo_Create
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/5bada39e8532ab4b75aaa28b80cdcee21bf19ab7/BasicJava_2018/TimestampDemo_Create/?at=master
See also:
No comments:
Post a Comment