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 enum
The configuration of the date parser. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
private boolean
private boolean
private int
private int
private int
private int
private boolean
private String
private final ToDateParser.ConfigParam
private int
private int
private boolean
private String
private boolean
private int
private int
private int
private int
private final SessionLocal
private TimeZoneProvider
private boolean
private int
private int
private final String
private final String
private int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ToDateParser
(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) String
private ValueTimestamp
private ValueTimestampTimeZone
private static ToDateParser
getTimestampParser
(SessionLocal session, ToDateParser.ConfigParam param, String input, String format) private boolean
private static ToDateParser
private void
(package private) void
Remove a token from a string.private void
(package private) void
setAbsoluteDay
(int absoluteDay) (package private) void
setAmPm
(boolean isAM) (package private) void
setBC
(boolean bc) (package private) void
setDay
(int day) (package private) void
setDayOfYear
(int dayOfYear) (package private) void
setHour
(int hour) (package private) void
setHour12
(int hour12) (package private) void
setMinute
(int minute) (package private) void
setMonth
(int month) (package private) void
setNanos
(int nanos) (package private) void
setSecond
(int second) (package private) void
setTimeZone
(TimeZoneProvider timeZone) (package private) void
setTimeZoneHour
(int timeZoneHour) (package private) void
setTimeZoneMinute
(int timeZoneMinute) (package private) void
setYear
(int year) static ValueTimestamp
toDate
(SessionLocal session, String input, String format) Parse a string as a date with the given format.toString()
static ValueTimestamp
toTimestamp
(SessionLocal session, String input, String format) Parse a string as a timestamp with the given format.static ValueTimestampTimeZone
toTimestampTz
(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
-