Instant parse() method in Java with Examples
The parse() method of Instant class help to get an instance of Instant from a string value passed as parameter. This string is an instant in the UTC time zone. It is parsed using DateTimeFormatter.ISO_INSTANT.
public static Instant parse(CharSequence text)
Parameters: This method accepts one parameter text which is the text to parse in instant. It should not be null.
Returns: This method returns an Instant which is the valid instant in the UTC time xone of the String passed as the parameter.
Exception: This method throws DateTimeException if the text cannot be parsed.
Below programs illustrate the parse() method:
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.