Module org.tquadrat.foundation.util
Class YearStringConverter
java.lang.Object
org.tquadrat.foundation.util.stringconverter.TimeDateStringConverter<Year>
org.tquadrat.foundation.util.stringconverter.YearStringConverter
- All Implemented Interfaces:
Serializable,StringConverter<Year>
@ClassVersion(sourceVersion="$Id: YearStringConverter.java 1130 2024-05-05 16:16:09Z tquadrat $")
@API(status=STABLE,
since="0.0.6")
public class YearStringConverter
extends TimeDateStringConverter<Year>
The implementation of
TimeDateStringConverter
for java.time.Year.- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: YearStringConverter.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.YearStringConverter"
-
Field Summary
FieldsFields inherited from class org.tquadrat.foundation.util.stringconverter.TimeDateStringConverter
MSG_InvalidDateTimeFormatFields inherited from interface org.tquadrat.foundation.lang.StringConverter
METHOD_NAME_GetSubjectClass, METHOD_NAME_Provider -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newYearStringConverterinstance.YearStringConverter(DateTimeFormatter formatter) Creates a newYearStringConverterinstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected final YearparseDateTime(CharSequence source, Optional<DateTimeFormatter> formatter) Parses the given String to an instance ofTemporal.static final YearStringConverterprovider()This method is used by theServiceLoaderto obtain the instance for thisStringConverterimplementation.Methods inherited from class org.tquadrat.foundation.util.stringconverter.TimeDateStringConverter
fromString, getSubjectClass, toString
-
Field Details
-
INSTANCE
An instance of this class.
-
-
Constructor Details
-
YearStringConverter
public YearStringConverter()Creates a newYearStringConverterinstance. -
YearStringConverter
Creates a newYearStringConverterinstance.- Parameters:
formatter- The formatter for the temporal accessor.
-
-
Method Details
-
parseDateTime
protected final Year parseDateTime(CharSequence source, Optional<DateTimeFormatter> formatter) throws DateTimeParseException Parses the given String to an instance ofTemporal. The caller ensures thatsourceis notnull, not the empty String and does not contain only whitespace.- Specified by:
parseDateTimein classTimeDateStringConverter<Year>- 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 theServiceLoaderto obtain the instance for thisStringConverterimplementation.- Returns:
- The instance for this
StringConverterimplementation.
-
