Skip to main content
Version: Java (Groovy)

parseInstantQuiet

parseInstantQuiet parses a string argument as an Instant, which represents a specific point in time. Resolution can be as precise as a millisecond.

Instant strings are formatted according to the ISO-8601 date-time format as yyyy-MM-ddThh:mm:ss[.SSSSSSSSS] TZ.

"Quiet" methods return null instead of throwing an exception when encountering a string that cannot be parsed.

Syntax

parseInstantQuiet(s)

Parameters

ParameterTypeDescription
sstring

The string to be converted.

Date-time strings can be formatted as yyyy-MM-ddThh:mm:ss[.SSSSSSSSS] TZ.

Returns

An Instant, or null if invalid input is given.

Examples

time = "1995-08-02 ET"

time2 = "2008-11-11T08:12:23.231453 ET"

time3 = "invalid time"

println parseInstantQuiet(time)

println parseInstantQuiet(time2)

println parseInstantQuiet(time3)