- java.lang.Object
-
- io.github.mmm.base.temporal.TemporalParser
-
- All Implemented Interfaces:
FromStringParser<Temporal>
public final class TemporalParser extends Object implements FromStringParser<Temporal>
Parser that can detectString
s representing aTemporal
value viaparse(String)
but returnsnull
if not aTemporal
instead of throwing an exception.- Since:
- 1.0.0
- See Also:
parse(String)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TemporalParser
get()
Temporal
parse(String value)
Parses the givenString
to the type handled by this parser but efficiently returnsnull
if the syntax does not match.
-
-
-
Method Detail
-
parse
public Temporal parse(String value)
Description copied from interface:FromStringParser
Parses the givenString
to the type handled by this parser but efficiently returnsnull
if the syntax does not match. This allows to detect the format without wasting much performance.- Specified by:
parse
in interfaceFromStringParser<Temporal>
- Parameters:
value
- thedefault string representation
of a (potential)Temporal
value. This can beInstant
,LocalDate
,LocalTime
,LocalDateTime
,OffsetTime
,OffsetDateTime
,ZonedDateTime
, orYearMonth
. Please note thatChronoLocalDate
such asHijrahDate
,JapaneseDate
,MinguoDate
, orThaiBuddhistDate
are not supported. AlsoYear
is not supported as it can easily be confused with a regular integer and can also be detected easily with just two lines of code.- Returns:
- the given
value
parsed asTemporal
ornull
if not any of the supportedTemporal
types.
-
get
public static TemporalParser get()
- Returns:
- the singleton instance of this
FromStringParser
forTemporal
.
-
-