Click here to watch on Youtube :
https://www.youtube.com/watch?v=jKVbaIXOXzU&list=UUhwKlOVR041tngjerWxVccw
ZoneDateTimeDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/ZoneDateTimeDemo_with.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ZoneDateTimeDemo_with
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/6f1f0d2759f060503c7b9e4a4259ae3ddbfe139e/BasicJava/ZoneDateTimeDemo_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=jKVbaIXOXzU&list=UUhwKlOVR041tngjerWxVccw
ZoneDateTimeDemo.java
import java.time.ZonedDateTime;
public class ZoneDateTimeDemo
{
public static void main(String[] args)
{
ZonedDateTime zonedDateTime1 = ZonedDateTime.parse("2017-02-03T10:15:30+01:00");
System.out.println("zonedDateTime1 = "+zonedDateTime1);
ZonedDateTime zonedDateTime2 = zonedDateTime1.withYear(2018);
System.out.println("\nYear changed = "+zonedDateTime2);
ZonedDateTime zonedDateTime3 = zonedDateTime2.withMonth(10);
System.out.println("Month changed = "+zonedDateTime3);
ZonedDateTime zonedDateTime4 = zonedDateTime3.withDayOfMonth(25);
System.out.println("Day changed = "+zonedDateTime4);
ZonedDateTime zonedDateTime5 = zonedDateTime4.withHour(1);
System.out.println("Hour changed = "+zonedDateTime5);
ZonedDateTime zonedDateTime6 = zonedDateTime5.withMinute(10);
System.out.println("Min changed = "+zonedDateTime6);
ZonedDateTime zonedDateTime7 = zonedDateTime6.withSecond(20);
System.out.println("Sec changed = "+zonedDateTime7);
ZonedDateTime zonedDateTime8 = zonedDateTime7.withNano(50);
System.out.println("NanoSec changed = "+zonedDateTime8);
}
}
public class ZoneDateTimeDemo
{
public static void main(String[] args)
{
ZonedDateTime zonedDateTime1 = ZonedDateTime.parse("2017-02-03T10:15:30+01:00");
System.out.println("zonedDateTime1 = "+zonedDateTime1);
ZonedDateTime zonedDateTime2 = zonedDateTime1.withYear(2018);
System.out.println("\nYear changed = "+zonedDateTime2);
ZonedDateTime zonedDateTime3 = zonedDateTime2.withMonth(10);
System.out.println("Month changed = "+zonedDateTime3);
ZonedDateTime zonedDateTime4 = zonedDateTime3.withDayOfMonth(25);
System.out.println("Day changed = "+zonedDateTime4);
ZonedDateTime zonedDateTime5 = zonedDateTime4.withHour(1);
System.out.println("Hour changed = "+zonedDateTime5);
ZonedDateTime zonedDateTime6 = zonedDateTime5.withMinute(10);
System.out.println("Min changed = "+zonedDateTime6);
ZonedDateTime zonedDateTime7 = zonedDateTime6.withSecond(20);
System.out.println("Sec changed = "+zonedDateTime7);
ZonedDateTime zonedDateTime8 = zonedDateTime7.withNano(50);
System.out.println("NanoSec changed = "+zonedDateTime8);
}
}
Output
zonedDateTime1 = 2017-02-03T10:15:30+01:00
Year changed = 2018-02-03T10:15:30+01:00
Month changed = 2018-10-03T10:15:30+01:00
Day changed = 2018-10-25T10:15:30+01:00
Hour changed = 2018-10-25T01:15:30+01:00
Min changed = 2018-10-25T01:10:30+01:00
Sec changed = 2018-10-25T01:10:20+01:00
NanoSec changed = 2018-10-25T01:10:20.000000050+01:00
Year changed = 2018-02-03T10:15:30+01:00
Month changed = 2018-10-03T10:15:30+01:00
Day changed = 2018-10-25T10:15:30+01:00
Hour changed = 2018-10-25T01:15:30+01:00
Min changed = 2018-10-25T01:10:30+01:00
Sec changed = 2018-10-25T01:10:20+01:00
NanoSec changed = 2018-10-25T01:10:20.000000050+01:00
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/ZoneDateTimeDemo_with.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ZoneDateTimeDemo_with
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/6f1f0d2759f060503c7b9e4a4259ae3ddbfe139e/BasicJava/ZoneDateTimeDemo_with/?at=master
See also:
No comments:
Post a Comment