Click here to watch on Youtube:
https://www.youtube.com/watch?v=XFhMO5B78Xo&list=UUhwKlOVR041tngjerWxVccw
TimestampDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/TimestampDemo_valueOf_methods.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/TimestampDemo_valueOf_methods
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/5bada39e8532ab4b75aaa28b80cdcee21bf19ab7/BasicJava_2018/TimestampDemo_valueOf_methods/?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=XFhMO5B78Xo&list=UUhwKlOVR041tngjerWxVccw
TimestampDemo.java
import java.sql.Timestamp;
import java.time.LocalDateTime;
public class TimestampDemo
{
public static void main(String[] args)
{
LocalDateTime localDateTime = LocalDateTime.now();
System.out.println("localDateTime = " + localDateTime);
/*
* Obtains an instance of Timestamp from a LocalDateTime
* object, with the same year, month, day of month, hours,
* minutes, seconds and nanos date-time value as the provided
* LocalDateTime
*/
Timestamp timestamp = Timestamp.valueOf(localDateTime);
System.out.println(timestamp);
/*
* Parameters:
*
* s - timestamp in format yyyy-[m]m-[d]d hh:mm:ss[.f...]. The
* fractional seconds may be omitted. The leading zero for mm
* and dd may also be omitted.
*
* Returns:
*
* corresponding Timestamp value
*/
timestamp = Timestamp.valueOf("2013-01-23 19:09:58.743");
System.out.println(timestamp);
}
}
import java.time.LocalDateTime;
public class TimestampDemo
{
public static void main(String[] args)
{
LocalDateTime localDateTime = LocalDateTime.now();
System.out.println("localDateTime = " + localDateTime);
/*
* Obtains an instance of Timestamp from a LocalDateTime
* object, with the same year, month, day of month, hours,
* minutes, seconds and nanos date-time value as the provided
* LocalDateTime
*/
Timestamp timestamp = Timestamp.valueOf(localDateTime);
System.out.println(timestamp);
/*
* Parameters:
*
* s - timestamp in format yyyy-[m]m-[d]d hh:mm:ss[.f...]. The
* fractional seconds may be omitted. The leading zero for mm
* and dd may also be omitted.
*
* Returns:
*
* corresponding Timestamp value
*/
timestamp = Timestamp.valueOf("2013-01-23 19:09:58.743");
System.out.println(timestamp);
}
}
Output
localDateTime = 2018-11-13T09:59:07.900
2018-11-13 09:59:07.9
2013-01-23 19:09:58.743
2018-11-13 09:59:07.9
2013-01-23 19:09:58.743
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/TimestampDemo_valueOf_methods.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/TimestampDemo_valueOf_methods
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/5bada39e8532ab4b75aaa28b80cdcee21bf19ab7/BasicJava_2018/TimestampDemo_valueOf_methods/?at=master
See also:
No comments:
Post a Comment