Java Instant getLong() methodThe getLong() method of Java Instant class is used to get the value of the specified field from this instant as a long. This returns for the value of the specified field. If it is not possible to return the value because the field is not supported or for some other reason, it throws an exception. SyntaxParametersfield- The value for the field. ReturnThe value of the field. ExceptionsDateTimeException - If a value for the field cannot be obtained or the value is outside the range of valid values for the field. UnsupportedTemporalTypeException - If the field is not supported or the range of values exceeds an int. ArithmeticException - If numeric overflow occurs. Example 1Output: The output will be like this. 0 Example 2Output: The output will be like this. 2018-08-10T06:00:07.269Z NanoOfSecond > 269000000 -- NanoOfDay not supported MicroOfSecond > 269000 -- MicroOfDay not supported MilliOfSecond > 269 -- 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 not supported -- DayOfYear not supported -- EpochDay not supported -- AlignedWeekOfMonth not supported -- AlignedWeekOfYear not supported -- MonthOfYear not supported -- ProlepticMonth not supported -- YearOfEra not supported -- Year not supported -- Era not supported InstantSeconds > 1533880807 -- OffsetSeconds not supported Next TopicJava-instant-getepochsecond-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India