Package com.ethlo.time.internal
Class ItuDurationParser
- java.lang.Object
-
- com.ethlo.time.internal.ItuDurationParser
-
public class ItuDurationParser extends java.lang.Object
Rationale Against Supporting Years and MonthsSupporting years (Y) and months (M) in duration calculations is problematic due to:
Variable Lengths: Months have different lengths (28-31 days), and years may be leap or non-leap (365 vs. 366 days). This makes durations ambiguous unless referenced to a specific start date.
Context-Dependent Interpretation: P1M could mean 28, 29, 30, or 31 days depending on the month in which it is applied.
Difficult Arithmetic: Operations like addition and comparison require anchoring to a specific date, making them non-trivial in purely arithmetic computations.
Consistency Issues: Excluding years and months ensures durations are always exact and unambiguous, aligning with precise time-based measurements.
-
-
Field Summary
Fields Modifier and Type Field Description static char
DIGIT_NINE
static char
DIGIT_ZERO
static char
DOT
static char
MINUS
static int
NANOS_IN_SECOND
static char
SEP_T
static char
UNIT_DAY
static char
UNIT_HOUR
static char
UNIT_MINUTE
static char
UNIT_SECOND
static char
UNIT_UNDEFINED
static char
UNIT_WEEK
-
Constructor Summary
Constructors Constructor Description ItuDurationParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Duration
parse(java.lang.String chars)
static Duration
parse(java.lang.String text, int offset)
private static int
readUntilNonDigit(java.lang.String text, int offset, DurationPartsConsumer consumer)
-
-
-
Field Detail
-
NANOS_IN_SECOND
public static final int NANOS_IN_SECOND
- See Also:
- Constant Field Values
-
SEP_T
public static final char SEP_T
- See Also:
- Constant Field Values
-
UNIT_WEEK
public static final char UNIT_WEEK
- See Also:
- Constant Field Values
-
UNIT_DAY
public static final char UNIT_DAY
- See Also:
- Constant Field Values
-
UNIT_HOUR
public static final char UNIT_HOUR
- See Also:
- Constant Field Values
-
UNIT_MINUTE
public static final char UNIT_MINUTE
- See Also:
- Constant Field Values
-
UNIT_SECOND
public static final char UNIT_SECOND
- See Also:
- Constant Field Values
-
DOT
public static final char DOT
- See Also:
- Constant Field Values
-
DIGIT_ZERO
public static final char DIGIT_ZERO
- See Also:
- Constant Field Values
-
DIGIT_NINE
public static final char DIGIT_NINE
- See Also:
- Constant Field Values
-
MINUS
public static final char MINUS
- See Also:
- Constant Field Values
-
UNIT_UNDEFINED
public static final char UNIT_UNDEFINED
- See Also:
- Constant Field Values
-
-
Method Detail
-
parse
public static Duration parse(java.lang.String chars)
-
parse
public static Duration parse(java.lang.String text, int offset)
-
readUntilNonDigit
private static int readUntilNonDigit(java.lang.String text, int offset, DurationPartsConsumer consumer)
-
-