Click here to watch on Youtube :
https://www.youtube.com/watch?v=xgQY7yLZqMs&list=UUhwKlOVR041tngjerWxVccw
LocalDateTimeDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/LocalDateTimeDemo_with.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/LocalDateTimeDemo_with
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/2732bd5046563d647669928b143687e5dbf4d99f/BasicJava/LocalDateTimeDemo_with/?at=master
See also:
All JavaEE Videos Playlist
All JavaEE Videos
All JAVA EE Links
Servlets Tutorial
All Design Patterns Links
JDBC Tutorial
Java Collection Framework Tutorial
JAVA Tutorial
Kids Tutorial
https://www.youtube.com/watch?v=xgQY7yLZqMs&list=UUhwKlOVR041tngjerWxVccw
LocalDateTimeDemo.java
import java.time.LocalDateTime;
public class LocalDateTimeDemo
{
public static void main(String[] args)
{
LocalDateTime localDateTime1 = LocalDateTime.parse("2017-01-03T20:25:30");
System.out.println("date and Time = "+localDateTime1);
LocalDateTime localDateTime2 = localDateTime1.withYear(2018);
System.out.println("\nYear changed = "+localDateTime2);
LocalDateTime localDateTime3 = localDateTime2.withMonth(10);
System.out.println("Month changed = "+localDateTime3);
LocalDateTime localDateTime4 = localDateTime3.withDayOfMonth(25);
System.out.println("Day changed = "+localDateTime4);
LocalDateTime localDateTime5 = localDateTime4.withHour(1);
System.out.println("Hour changed = "+localDateTime5);
LocalDateTime localDateTime6 = localDateTime5.withMinute(10);
System.out.println("Min changed = "+localDateTime6);
LocalDateTime localDateTime7 = localDateTime6.withSecond(20);
System.out.println("Sec changed = "+localDateTime7);
LocalDateTime localDateTime8 = localDateTime7.withNano(50);
System.out.println("NanoSec changed = "+localDateTime8);
}
}
public class LocalDateTimeDemo
{
public static void main(String[] args)
{
LocalDateTime localDateTime1 = LocalDateTime.parse("2017-01-03T20:25:30");
System.out.println("date and Time = "+localDateTime1);
LocalDateTime localDateTime2 = localDateTime1.withYear(2018);
System.out.println("\nYear changed = "+localDateTime2);
LocalDateTime localDateTime3 = localDateTime2.withMonth(10);
System.out.println("Month changed = "+localDateTime3);
LocalDateTime localDateTime4 = localDateTime3.withDayOfMonth(25);
System.out.println("Day changed = "+localDateTime4);
LocalDateTime localDateTime5 = localDateTime4.withHour(1);
System.out.println("Hour changed = "+localDateTime5);
LocalDateTime localDateTime6 = localDateTime5.withMinute(10);
System.out.println("Min changed = "+localDateTime6);
LocalDateTime localDateTime7 = localDateTime6.withSecond(20);
System.out.println("Sec changed = "+localDateTime7);
LocalDateTime localDateTime8 = localDateTime7.withNano(50);
System.out.println("NanoSec changed = "+localDateTime8);
}
}
Output
date and Time = 2017-01-03T20:25:30
Year changed = 2018-01-03T20:25:30
Month changed = 2018-10-03T20:25:30
Day changed = 2018-10-25T20:25:30
Hour changed = 2018-10-25T01:25:30
Min changed = 2018-10-25T01:10:30
Sec changed = 2018-10-25T01:10:20
NanoSec changed = 2018-10-25T01:10:20.000000050
Year changed = 2018-01-03T20:25:30
Month changed = 2018-10-03T20:25:30
Day changed = 2018-10-25T20:25:30
Hour changed = 2018-10-25T01:25:30
Min changed = 2018-10-25T01:10:30
Sec changed = 2018-10-25T01:10:20
NanoSec changed = 2018-10-25T01:10:20.000000050
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/LocalDateTimeDemo_with.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/LocalDateTimeDemo_with
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/2732bd5046563d647669928b143687e5dbf4d99f/BasicJava/LocalDateTimeDemo_with/?at=master
See also:
No comments:
Post a Comment