Module org.tquadrat.foundation.util
Class YearMonthStringConverter
java.lang.Object
org.tquadrat.foundation.util.stringconverter.TimeDateStringConverter<YearMonth>
org.tquadrat.foundation.util.stringconverter.YearMonthStringConverter
- All Implemented Interfaces:
Serializable
,StringConverter<YearMonth>
@ClassVersion(sourceVersion="$Id: YearMonthStringConverter.java 1130 2024-05-05 16:16:09Z tquadrat $")
@API(status=STABLE,
since="0.0.6")
public class YearMonthStringConverter
extends TimeDateStringConverter<YearMonth>
The implementation of
TimeDateStringConverter
for java.time.YearMonth
.- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: YearMonthStringConverter.java 1130 2024-05-05 16:16:09Z tquadrat $
- Since:
- 0.0.6
- See Also:
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.util.stringconverter.YearMonthStringConverter"
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final YearMonthStringConverter
An instance of this class.Fields inherited from class org.tquadrat.foundation.util.stringconverter.TimeDateStringConverter
MSG_InvalidDateTimeFormat
Fields inherited from interface org.tquadrat.foundation.lang.StringConverter
METHOD_NAME_GetSubjectClass, METHOD_NAME_Provider
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newYearMonthStringConverter
instance.YearMonthStringConverter
(DateTimeFormatter formatter) Creates a newYearMonthStringConverter
instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected final YearMonth
parseDateTime
(CharSequence source, Optional<DateTimeFormatter> formatter) Parses the given String to an instance ofTemporal
.static final YearMonthStringConverter
provider()
This method is used by theServiceLoader
to obtain the instance for thisStringConverter
implementation.Methods inherited from class org.tquadrat.foundation.util.stringconverter.TimeDateStringConverter
fromString, getSubjectClass, toString
-
Field Details
-
Constructor Details
-
YearMonthStringConverter
public YearMonthStringConverter()Creates a newYearMonthStringConverter
instance. -
YearMonthStringConverter
Creates a newYearMonthStringConverter
instance.- Note:
-
- The formatter may not drop neither year nor month, otherwise
fromString()
may fail. This means that the formatter is only allowed to re-order the temporal fields.
- The formatter may not drop neither year nor month, otherwise
- Parameters:
formatter
- The formatter for the temporal accessor.
-
-
Method Details
-
parseDateTime
protected final YearMonth parseDateTime(CharSequence source, Optional<DateTimeFormatter> formatter) throws DateTimeParseException Parses the given String to an instance ofTemporal
. The caller ensures thatsource
is notnull
, not the empty String and does not contain only whitespace.- Specified by:
parseDateTime
in classTimeDateStringConverter<YearMonth>
- Parameters:
source
- The String to parse.formatter
- The formatter for parsing the String- Returns:
- The time/date value.
- Throws:
DateTimeParseException
- The given value cannot be parsed to aTemporal
.
-
provider
This method is used by theServiceLoader
to obtain the instance for thisStringConverter
implementation.- Returns:
- The instance for this
StringConverter
implementation.
-