Package org.h2.mode
Class ToDateTokenizer
java.lang.Object
org.h2.mode.ToDateTokenizer
Emulates Oracle's TO_DATE function. This class knows all about the
TO_DATE-format conventions and how to parse the corresponding data.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
Parslet responsible for parsing day parameterstatic enum
The format tokens.(package private) static class
Parslet responsible for parsing year parameter(package private) static class
Parslet responsible for parsing month parameter(package private) static class
Parslet responsible for parsing time parameter(package private) static interface
Interface of the classes that can parse a specialized small bit of the TO_DATE format-string.(package private) static class
Parslet responsible for parsing year parameter -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final ToDateTokenizer.DayParslet
The parslet for a day.(package private) static final ToDateTokenizer.InlineParslet
The inline parslet.(package private) static final ToDateTokenizer.MonthParslet
The parslet for a month.(package private) static final ToDateTokenizer.TimeParslet
The parslet for time.(package private) static final ToDateTokenizer.YearParslet
The parslet for a year.(package private) static final Pattern
The pattern for "am" or "pm".(package private) static final Pattern
The pattern for "bc" or "ad".(package private) static final Pattern
The pattern for a fraction (of a second for example).(package private) static final Pattern
The pattern for four digits (typically a year).(package private) static final Pattern
The pattern for a number.(package private) static final Pattern
The pattern for a number.(package private) static final Pattern
The pattern for one digit.(package private) static final Pattern
The pattern for three digits.(package private) static final Pattern
The pattern for two digits.(package private) static final Pattern
The pattern for one or two digits.(package private) static final Pattern
The pattern 2-4 digits (e.g. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static String
matchStringOrThrow
(Pattern p, ToDateParser params, Enum<?> aEnum) Match the pattern, or if not possible throw an exception.(package private) static String
setByName
(ToDateParser params, int field) Set the given field in the calendar.(package private) static void
throwException
(ToDateParser params, String errorStr) Throw a parse exception.
-
Field Details
-
PATTERN_INLINE
The pattern for a number. -
PATTERN_NUMBER
The pattern for a number. -
PATTERN_FOUR_DIGITS
The pattern for four digits (typically a year). -
PATTERN_TWO_TO_FOUR_DIGITS
The pattern 2-4 digits (e.g. for RRRR). -
PATTERN_THREE_DIGITS
The pattern for three digits. -
PATTERN_TWO_DIGITS
The pattern for two digits. -
PATTERN_TWO_DIGITS_OR_LESS
The pattern for one or two digits. -
PATTERN_ONE_DIGIT
The pattern for one digit. -
PATTERN_FF
The pattern for a fraction (of a second for example). -
PATTERN_AM_PM
The pattern for "am" or "pm". -
PATTERN_BC_AD
The pattern for "bc" or "ad". -
PARSLET_YEAR
The parslet for a year. -
PARSLET_MONTH
The parslet for a month. -
PARSLET_DAY
The parslet for a day. -
PARSLET_TIME
The parslet for time. -
PARSLET_INLINE
The inline parslet. E.g. 'YYYY-MM-DD"T"HH24:MI:SS"Z"' where "T" and "Z" are inlined
-
-
Constructor Details
-
ToDateTokenizer
private ToDateTokenizer()
-
-
Method Details
-
matchStringOrThrow
Match the pattern, or if not possible throw an exception.- Parameters:
p
- the patternparams
- the parameters with the input stringaEnum
- the pattern name- Returns:
- the matched value
-
setByName
Set the given field in the calendar.- Parameters:
params
- the parameters with the input stringfield
- the field to set- Returns:
- the matched value
-
throwException
Throw a parse exception.- Parameters:
params
- the parameters with the input stringerrorStr
- the error string
-