Wednesday 14 March 2018

How to use from method of ZoneOffset Class | Java 8 Date and Time


Click here to watch on Youtube: 
https://www.youtube.com/watch?v=g-yb5hDpXB8&list=UUhwKlOVR041tngjerWxVccw

ZoneOffsetDemo.java

import java.time.ZoneOffset;
import java.time.ZonedDateTime;

public class ZoneOffsetDemo
{

    public static void main(String[] args)
    {

        ZonedDateTime zonedDateTime = ZonedDateTime.now();
        System.out.println("zonedDateTime = "+zonedDateTime);
       
        /*
         * Parameters:
         *
         * temporal - the temporal object to convert, not null
         *
         * Returns:
         *
         * the zone-offset, not null
         */

        ZoneOffset zoneOffset = ZoneOffset.from(zonedDateTime);
        System.out.println("zoneOffset = "+zoneOffset);
    }

}

Output

zonedDateTime = 2018-02-20T09:14:33.284+05:30[Asia/Calcutta]
zoneOffset = +05:30

Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/ZoneOffsetDemo_from.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/ZoneOffsetDemo_from

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/dc7c5f1cf2584c5bc7f3eb33e62ff414965c0d6f/BasicJava_2018/ZoneOffsetDemo_from/?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
  • Cooking Tutorial
  • No comments:

    Post a Comment