Class ParsedFields
java.lang.Object
io.github.connellite.util.internal.dateparse.ParsedFields
Mutable holder for the date-time fields collected by
DateTimeScanner and
DateTimePatterns.
Ranges are validated by the setters, so the to* methods never throw. A zone or offset
is recorded when present but does not shift the wall-clock fields: toLocalDateTime()
returns the date-time exactly as written.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intexpandTwoDigitYear(int twoDigitYear, int baseYear) Resolves a two-digit year against a sliding window starting 80 years beforebaseYear, the same pivotSimpleDateFormatuses.booleanhasDate()booleanbooleanhasTime()booleanhasZone()voidreset()Clears all fields so the instance can be reused for another input.booleansetDate(int year, int month, int day) Records the calendar date.booleansetOffsetSeconds(int offsetSeconds) Records a fixed offset from UTC.booleansetTime(int hour, int minute, int second, int nano) Records the time of day.voidRecords a named zone, and its current offset when no explicit offset was parsed.toZoneId()
-
Constructor Details
-
ParsedFields
public ParsedFields()
-
-
Method Details
-
reset
public void reset()Clears all fields so the instance can be reused for another input. -
setDate
public boolean setDate(int year, int month, int day) Records the calendar date.- Returns:
falsewhen the values do not form a real date, leaving the instance unchanged
-
setTime
public boolean setTime(int hour, int minute, int second, int nano) Records the time of day. Asecondof 60 (leap second) is clamped to 59.Based on Jackson: ISO8601Utils.parse (
if (seconds > 59 && seconds < 63) seconds = 59).- Returns:
falsewhen the values are out of range, leaving the instance unchanged
-
setOffsetSeconds
public boolean setOffsetSeconds(int offsetSeconds) Records a fixed offset from UTC.- Returns:
falsewhenoffsetSecondsexceeds theZoneOffsetrange
-
setZone
Records a named zone, and its current offset when no explicit offset was parsed. -
hasDate
public boolean hasDate() -
hasTime
public boolean hasTime() -
hasOffset
public boolean hasOffset() -
hasZone
public boolean hasZone() -
toLocalDate
- Returns:
- the calendar date, or
nullwhen the input carried no date
-
toLocalDateTime
- Returns:
- the date-time, using start of day when the input carried no time, or
nullwhen the input carried no date
-
toLocalTime
- Returns:
- the time of day,
LocalTime.MIDNIGHTfor a date without time, ornullwhen the input carried neither
-
toOffsetDateTime
- Returns:
- the date-time at the parsed offset, falling back to the parsed zone's offset and then
to UTC, or
nullwhen the input carried no date
-
toOffsetTime
- Returns:
- the time of day at the parsed offset or zone, or
nullwhen the input carried no time or neither an offset nor a zone
-
toZoneOffset
- Returns:
- the explicit offset written in the input, or
nullwhen there was none. A named zone is not turned into an offset.
-
toZoneId
- Returns:
- the named zone, or the explicit offset when the input named no zone,
or
nullwhen it carried neither
-
expandTwoDigitYear
public static int expandTwoDigitYear(int twoDigitYear, int baseYear) Resolves a two-digit year against a sliding window starting 80 years beforebaseYear, the same pivotSimpleDateFormatuses.Based on sqlite-jdbc: FastDateParser.adjustYear.
-