Wednesday 14 March 2018

How to use get method of ZoneOffset Class which accept TemporalField


Click here to watch on Youtube: 
https://www.youtube.com/watch?v=9s5NtKyS92I&list=UUhwKlOVR041tngjerWxVccw

ZoneOffsetDemo.java

import java.time.ZoneOffset;
import java.time.temporal.ChronoField;

public class ZoneOffsetDemo
{

    public static void main(String[] args)
    {

        ZoneOffset zoneOffset = ZoneOffset.of("+01:00");
        System.out.println("zoneOffset = " + zoneOffset);
        /*
         * Parameters:
         *
         * field - the field to get, not null
         *
         * Returns:
         *
         * the value for the field
         */

        int offsetSeconds = zoneOffset.get(ChronoField.OFFSET_SECONDS);

        System.out.println("offsetSeconds = " + offsetSeconds);
    }

}

Output

zoneOffset = +01:00
offsetSeconds = 3600

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/ZoneOffsetDemo_get_field.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ZoneOffsetDemo_get_field

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/dc7c5f1cf2584c5bc7f3eb33e62ff414965c0d6f/BasicJava/ZoneOffsetDemo_get_field/?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