Wednesday 14 March 2018

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


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

ZoneOffsetDemo.java

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

public class ZoneOffsetDemo
{

    public static void main(String[] args)
    {
        ZoneOffset zoneOffset = ZoneOffset.UTC;

        /*
         * Parameters:
         *
         * field - the field to query the range for, not null
         *
         * Returns:
         *
         * the range of valid values for the field, not null
         */


        ValueRange range = zoneOffset.range(ChronoField.OFFSET_SECONDS);
        System.out.println("range = "+range);
        System.out.println("Max = " + range.getMaximum());
        System.out.println("Min = " + range.getMinimum());
    }

}

Output

range = -64800 - 64800
Max = 64800
Min = -64800

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

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

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