Close

Java Date Time - OffsetTime.range() Examples

Java Date Time Java Java API 


Class:

java.time.OffsetTime

java.lang.Objectjava.lang.Objectjava.time.OffsetTimejava.time.OffsetTimejava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public ValueRange range(TemporalField field)

This method returns the ValueRange object for the specified field.


Examples


package com.logicbig.example.offsettime;

import java.time.DateTimeException;
import java.time.OffsetTime;
import java.time.temporal.ChronoField;
import java.time.temporal.ValueRange;

public class RangeExample {

public static void main(String... args) {
OffsetTime t = OffsetTime.now();
System.out.println(t);

for (ChronoField cf : ChronoField.values()) {
try {
ValueRange range = t.range(cf);
System.out.printf("Range for %18s : %s%n", cf.name(), range);
} catch (DateTimeException e) {
System.out.printf(" -- %s not supported%n", cf.name());
}
}
}
}

Output

16:13:05.629-05:00
Range for NANO_OF_SECOND : 0 - 999999999
Range for NANO_OF_DAY : 0 - 86399999999999
Range for MICRO_OF_SECOND : 0 - 999999
Range for MICRO_OF_DAY : 0 - 86399999999
Range for MILLI_OF_SECOND : 0 - 999
Range for MILLI_OF_DAY : 0 - 86399999
Range for SECOND_OF_MINUTE : 0 - 59
Range for SECOND_OF_DAY : 0 - 86399
Range for MINUTE_OF_HOUR : 0 - 59
Range for MINUTE_OF_DAY : 0 - 1439
Range for HOUR_OF_AMPM : 0 - 11
Range for CLOCK_HOUR_OF_AMPM : 1 - 12
Range for HOUR_OF_DAY : 0 - 23
Range for CLOCK_HOUR_OF_DAY : 1 - 24
Range for AMPM_OF_DAY : 0 - 1
-- DAY_OF_WEEK not supported
-- ALIGNED_DAY_OF_WEEK_IN_MONTH not supported
-- ALIGNED_DAY_OF_WEEK_IN_YEAR not supported
-- DAY_OF_MONTH not supported
-- DAY_OF_YEAR not supported
-- EPOCH_DAY not supported
-- ALIGNED_WEEK_OF_MONTH not supported
-- ALIGNED_WEEK_OF_YEAR not supported
-- MONTH_OF_YEAR not supported
-- PROLEPTIC_MONTH not supported
-- YEAR_OF_ERA not supported
-- YEAR not supported
-- ERA not supported
-- INSTANT_SECONDS not supported
Range for OFFSET_SECONDS : -64800 - 64800




See Also