Package org.h2.mode

Class ToDateParser

java.lang.Object
org.h2.mode.ToDateParser

public final class ToDateParser extends Object
Emulates Oracle's TO_DATE function.
This class holds and handles the input data form the TO_DATE-method
  • Field Details

    • session

      private final SessionLocal session
    • unmodifiedInputStr

      private final String unmodifiedInputStr
    • unmodifiedFormatStr

      private final String unmodifiedFormatStr
    • functionName

      private final ToDateParser.ConfigParam functionName
    • inputStr

      private String inputStr
    • formatStr

      private String 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

      private TimeZoneProvider 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 session
      functionName - one of [TO_DATE, TO_TIMESTAMP] (both share the same code)
      input - the input date with the date-time info
      format - the format of date-time info
  • Method Details

    • getTimestampParser

      private static ToDateParser getTimestampParser(SessionLocal session, ToDateParser.ConfigParam param, String input, String format)
    • getResultingValue

      private ValueTimestamp getResultingValue()
    • getResultingValueWithTimeZone

      private ValueTimestampTimeZone 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

      void setTimeZone(TimeZoneProvider timeZone)
    • setTimeZoneHour

      void setTimeZoneHour(int timeZoneHour)
    • setTimeZoneMinute

      void setTimeZoneMinute(int timeZoneMinute)
    • hasToParseData

      private boolean hasToParseData()
    • removeFirstChar

      private void removeFirstChar()
    • parse

      private static ToDateParser parse(ToDateParser p)
    • remove

      void remove(String inputFragmentStr, String formatFragment)
      Remove a token from a string.
      Parameters:
      inputFragmentStr - the input fragment
      formatFragment - the format fragment
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toTimestamp

      public static ValueTimestamp toTimestamp(SessionLocal session, String input, String format)
      Parse a string as a timestamp with the given format.
      Parameters:
      session - the database session
      input - the input
      format - 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 session
      input - the input
      format - the format
      Returns:
      the timestamp
    • toDate

      public static ValueTimestamp toDate(SessionLocal session, String input, String format)
      Parse a string as a date with the given format.
      Parameters:
      session - the database session
      input - the input
      format - the format
      Returns:
      the date as a timestamp