Package org.h2.mode
Class ToDateParser
java.lang.Object
org.h2.mode.ToDateParser
Emulates Oracle's TO_DATE function.
This class holds and handles the input data form the TO_DATE-method
This class holds and handles the input data form the TO_DATE-method
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumThe configuration of the date parser. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate booleanprivate booleanprivate intprivate intprivate intprivate intprivate booleanprivate Stringprivate final ToDateParser.ConfigParamprivate intprivate intprivate booleanprivate Stringprivate booleanprivate intprivate intprivate intprivate intprivate final SessionLocalprivate TimeZoneProviderprivate booleanprivate intprivate intprivate final Stringprivate final Stringprivate int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateToDateParser(SessionLocal session, ToDateParser.ConfigParam functionName, String input, String format) -
Method Summary
Modifier and TypeMethodDescription(package private) int(package private) int(package private) String(package private) String(package private) Stringprivate ValueTimestampprivate ValueTimestampTimeZoneprivate static ToDateParsergetTimestampParser(SessionLocal session, ToDateParser.ConfigParam param, String input, String format) private booleanprivate static ToDateParserprivate void(package private) voidRemove a token from a string.private void(package private) voidsetAbsoluteDay(int absoluteDay) (package private) voidsetAmPm(boolean isAM) (package private) voidsetBC(boolean bc) (package private) voidsetDay(int day) (package private) voidsetDayOfYear(int dayOfYear) (package private) voidsetHour(int hour) (package private) voidsetHour12(int hour12) (package private) voidsetMinute(int minute) (package private) voidsetMonth(int month) (package private) voidsetNanos(int nanos) (package private) voidsetSecond(int second) (package private) voidsetTimeZone(TimeZoneProvider timeZone) (package private) voidsetTimeZoneHour(int timeZoneHour) (package private) voidsetTimeZoneMinute(int timeZoneMinute) (package private) voidsetYear(int year) static ValueTimestamptoDate(SessionLocal session, String input, String format) Parse a string as a date with the given format.toString()static ValueTimestamptoTimestamp(SessionLocal session, String input, String format) Parse a string as a timestamp with the given format.static ValueTimestampTimeZonetoTimestampTz(SessionLocal session, String input, String format) Parse a string as a timestamp with the given format.
-
Field Details
-
session
-
unmodifiedInputStr
-
unmodifiedFormatStr
-
functionName
-
inputStr
-
formatStr
-
doyValid
private boolean doyValid -
absoluteDayValid
private boolean absoluteDayValid -
hour12Valid
private boolean hour12Valid -
timeZoneHMValid
private boolean timeZoneHMValid -
bc
private boolean bc -
absoluteDay
private long absoluteDay -
year
private int year -
month
private int month -
day
private int day -
dayOfYear
private int dayOfYear -
hour
private int hour -
minute
private int minute -
second
private int second -
nanos
private int nanos -
hour12
private int hour12 -
isAM
private boolean isAM -
timeZone
-
timeZoneHour
private int timeZoneHour -
timeZoneMinute
private int timeZoneMinute -
currentYear
private int currentYear -
currentMonth
private int currentMonth
-
-
Constructor Details
-
ToDateParser
private ToDateParser(SessionLocal session, ToDateParser.ConfigParam functionName, String input, String format) - Parameters:
session- the database sessionfunctionName- one of [TO_DATE, TO_TIMESTAMP] (both share the same code)input- the input date with the date-time infoformat- the format of date-time info
-
-
Method Details
-
getTimestampParser
private static ToDateParser getTimestampParser(SessionLocal session, ToDateParser.ConfigParam param, String input, String format) -
getResultingValue
-
getResultingValueWithTimeZone
-
getInputStr
String getInputStr() -
getFormatStr
String getFormatStr() -
getFunctionName
String getFunctionName() -
queryCurrentYearAndMonth
private void queryCurrentYearAndMonth() -
getCurrentYear
int getCurrentYear() -
getCurrentMonth
int getCurrentMonth() -
setAbsoluteDay
void setAbsoluteDay(int absoluteDay) -
setBC
void setBC(boolean bc) -
setYear
void setYear(int year) -
setMonth
void setMonth(int month) -
setDay
void setDay(int day) -
setDayOfYear
void setDayOfYear(int dayOfYear) -
setHour
void setHour(int hour) -
setMinute
void setMinute(int minute) -
setSecond
void setSecond(int second) -
setNanos
void setNanos(int nanos) -
setAmPm
void setAmPm(boolean isAM) -
setHour12
void setHour12(int hour12) -
setTimeZone
-
setTimeZoneHour
void setTimeZoneHour(int timeZoneHour) -
setTimeZoneMinute
void setTimeZoneMinute(int timeZoneMinute) -
hasToParseData
private boolean hasToParseData() -
removeFirstChar
private void removeFirstChar() -
parse
-
remove
Remove a token from a string.- Parameters:
inputFragmentStr- the input fragmentformatFragment- the format fragment
-
toString
-
toTimestamp
Parse a string as a timestamp with the given format.- Parameters:
session- the database sessioninput- the inputformat- the format- Returns:
- the timestamp
-
toTimestampTz
public static ValueTimestampTimeZone toTimestampTz(SessionLocal session, String input, String format) Parse a string as a timestamp with the given format.- Parameters:
session- the database sessioninput- the inputformat- the format- Returns:
- the timestamp
-
toDate
Parse a string as a date with the given format.- Parameters:
session- the database sessioninput- the inputformat- the format- Returns:
- the date as a timestamp
-