The getLong() method of LocalDate class in Java gets the era applicable at this date.
public long getLong(TemporalField field)
Parameter: This method accepts a single mandatory parameter field which specifies the field to get and not null.
Return Value: The function returns the value for the field.
Exceptions: The program throws three exceptions which are described as below:
- DateTimeException: thrown if a value for the field cannot be obtained or the value is outside the range of valid values for the field.
- UnsupportedTemporalTypeException: thrown if the field is not supported or the range of values exceeds an long.
- ArithmeticException: thrown if numeric overflow occurs
Below programs illustrate the getLong() method of LocalDate in Java:
java.time.format.DateTimeParseException: Text '2017-01-32' could not be parsed: Invalid value for DayOfMonth (valid values 1 - 28/31): 32
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.