Package org.h2.mode

Class ToDateParser


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

      • unmodifiedInputStr

        private final java.lang.String unmodifiedInputStr
      • unmodifiedFormatStr

        private final java.lang.String unmodifiedFormatStr
      • inputStr

        private java.lang.String inputStr
      • formatStr

        private java.lang.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
      • timeZoneHour

        private int timeZoneHour
      • timeZoneMinute

        private int timeZoneMinute
      • currentYear

        private int currentYear
      • currentMonth

        private int currentMonth
    • Constructor Detail

      • ToDateParser

        private ToDateParser​(SessionLocal session,
                             ToDateParser.ConfigParam functionName,
                             java.lang.String input,
                             java.lang.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 Detail

      • getInputStr

        java.lang.String getInputStr()
      • getFormatStr

        java.lang.String getFormatStr()
      • getFunctionName

        java.lang.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)
      • setTimeZoneHour

        void setTimeZoneHour​(int timeZoneHour)
      • setTimeZoneMinute

        void setTimeZoneMinute​(int timeZoneMinute)
      • hasToParseData

        private boolean hasToParseData()
      • removeFirstChar

        private void removeFirstChar()
      • remove

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

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

        public static ValueTimestamp toTimestamp​(SessionLocal session,
                                                 java.lang.String input,
                                                 java.lang.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,
                                                           java.lang.String input,
                                                           java.lang.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,
                                            java.lang.String input,
                                            java.lang.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