Close

Java Date Time - MonthDay.getLong() Examples

Java Date Time Java Java API 


Class:

java.time.MonthDay

java.lang.Objectjava.lang.Objectjava.time.MonthDayjava.time.MonthDayjava.time.temporal.TemporalAccessorTemporalAccessorjava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public long getLong(TemporalField field)

This method returns the value of the specified field from this month-day as a long.


Examples


package com.logicbig.example.monthday;

import java.time.MonthDay;
import java.time.temporal.ChronoField;
import java.time.temporal.UnsupportedTemporalTypeException;

public class GetLongExample {

public static void main(String... args) {
MonthDay m = MonthDay.of(5, 21);
System.out.println(m);

for (ChronoField field : ChronoField.values()) {
try {
long l = m.getLong(field);
System.out.printf("%12s > %s%n", field, l);
} catch (UnsupportedTemporalTypeException e) {
System.out.printf(" -- %s not supported%n", field);
}
}
}
}

Output

--05-21
-- NanoOfSecond not supported
-- NanoOfDay not supported
-- MicroOfSecond not supported
-- MicroOfDay not supported
-- MilliOfSecond not supported
-- MilliOfDay not supported
-- SecondOfMinute not supported
-- SecondOfDay not supported
-- MinuteOfHour not supported
-- MinuteOfDay not supported
-- HourOfAmPm not supported
-- ClockHourOfAmPm not supported
-- HourOfDay not supported
-- ClockHourOfDay not supported
-- AmPmOfDay not supported
-- DayOfWeek not supported
-- AlignedDayOfWeekInMonth not supported
-- AlignedDayOfWeekInYear not supported
DayOfMonth > 21
-- DayOfYear not supported
-- EpochDay not supported
-- AlignedWeekOfMonth not supported
-- AlignedWeekOfYear not supported
MonthOfYear > 5
-- ProlepticMonth not supported
-- YearOfEra not supported
-- Year not supported
-- Era not supported
-- InstantSeconds not supported
-- OffsetSeconds not supported




See Also