Package oracle.sql

Class DATE

  • All Implemented Interfaces:
    java.io.Serializable, oracle.jdbc.internal.OracleDate

    public class DATE
    extends Datum
    implements oracle.jdbc.internal.OracleDate
    DATE Class


    The DATE class provides conversions between the Oracle Date (ldx_t) data type and Java classes java.sql.Date, java.sql.Time, java.sql.Timestamp

    The internal data for this object is stored as a seven byte array in the super class' storage area. The bytes are arranged as follows:

          Byte       Represents
           0         Century (19 for 1990)
           1         Decade  (90 for 1990)
           2         Month
           3         Day      
           4         Hour
           5         Minute
           6         Seconds
      

    Static methods are used for conversions.

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BDA
      Bad day: above range
      static int BDAL
      Bad day: below range
      static int BDT
      Bad date format
      static int BHR
      Bad hour: above range
      static int BHRL
      Bad hour: below range
      static int BMN
      Bad minute: above range
      static int BMNL
      Bad minute: below range
      static int BMO
      Bad month: above range
      static int BMOL
      Bad month: below range
      static int BSC
      Bad second: above range
      static int BSCL
      Bad second: below range
      static int BYR
      Bad year: above range
      static int BYRL
      Bad year: below range
      static int HRZER0
      Zero valued hour
      static int MIZERO
      Zero valued minute
      static int MSD
      Day is one of those "missing" from the year 1582
      static int SEZERO
      Zero valued second
      static int YR0
      Year zero does not exist
    • Constructor Summary

      Constructors 
      Constructor Description
      DATE()
      Constructs a DATE object initialized to 1/1/1970.
      DATE​(byte[] date)
      Create a DATE object represented by the given Oracle Date.
      DATE​(java.lang.Object obj)
      Constructs a DATE object initialized to the value specified by the object
      DATE​(java.lang.Object obj, java.util.Calendar cal)
      Constructs a DATE object initialized to the value specified by the object and a Calendar
      DATE​(java.lang.String str)
      Create a DATE object given a Java String object.
      DATE​(java.lang.String str, boolean lenient)
      Create a DATE object given a Java String object.
      DATE​(java.lang.String str, java.util.Calendar cal)
      Create a DATE object given a Java String object and a Calendar
      DATE​(java.sql.Date date)
      Create a DATE object given a Java Date object.
      DATE​(java.sql.Date date, java.util.Calendar cal)
      Create a DATE object given a Java Date object and a Calendar
      DATE​(java.sql.Time time)
      Create a DATE object given a Java Time object.
      DATE​(java.sql.Time time, java.util.Calendar cal)
      Create a DATE object given a Java Time object and a Calendar
      DATE​(java.sql.Timestamp timestamp)
      Create a DATE object given a Java Timestamp object
      DATE​(java.sql.Timestamp timestamp, java.util.Calendar cal)
      Create a DATE object given a Java Timestamp object and a Calendar
      DATE​(java.time.LocalDate ld)
      Create a DATE object given a Java LocalDate object
      DATE​(java.time.LocalDateTime ldt)
      Create a DATE object given a Java LocalDateTime object
      DATE​(java.time.LocalTime lt)
      Create a DATE object given a Java LocalTime object
      DATE​(java.time.OffsetDateTime odt)
      Create a DATE object given a Java OffsetDateTime object
      DATE​(java.time.OffsetTime ot)
      Create a DATE object given a Java OffsetTime object
      DATE​(java.time.ZonedDateTime zdt)
      Create a DATE object given a Java ZonedDateTime object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      DATE addJulianDays​(int julianDay, int julianSec)
      Add Julian days to a date.
      DATE addMonths​(int months)
      Add months to a date.
      static int checkValidity​(byte[] date)
      Checks the DATE passed in.
      int compareTo​(DATE date)
      Returns -1 if DATE is less than date, 0 if DATE and date are equal (==), 1 if DATE is greater than date.
      java.sql.Date dateValue()
      Calls toDate to convert internal Oracle DATE to a Java Date.
      java.sql.Date dateValue​(java.util.Calendar cal)
      Calls toDate to convert internal Oracle DATE and Calendar to a Java Date.
      void diffInJulianDays​(DATE date, int[] julianDay, int[] julianSec)
      Calculates the difference between two dates in Julian days.
      NUMBER diffInMonths​(DATE date)
      Calculates the difference between two dates in months.
      static DATE fromJulianDays​(int julianDay, int julianSec)
      Convert given julian days and seconds to an Oracle Date.
      static DATE fromText​(java.lang.String datestr, java.lang.String fmt, java.lang.String lang)
      Convert a string to a DATE object.
      static DATE getCurrentDate()
      Gets current date and time
      boolean isConvertibleTo​(java.lang.Class<?> cls)
      Determines if the object can be converted to a particular class
      DATE lastDayOfMonth()
      returns a DATE object intialized to the last day of the month .
      java.time.LocalDateTime localDateTimeValue()
      Converts DATE to LocalDateTime.
      java.time.LocalDate localDateValue()
      Converts DATE to LocalDate.
      java.time.LocalTime localTimeValue()
      Converts DATE to LocalTime.
      java.lang.Object makeJdbcArray​(int arraySize)
      Returns a JDBC array representation of the datum
      static void numberToJulianDays​(NUMBER num, int[] julianDay, int[] julianSec)
      Converts an Oracle NUMBER to Julian days and seconds
      static DATE of​(java.time.LocalDate ld)
      Creates DATE from the LocalDate.
      static DATE of​(java.time.LocalDateTime ldt)
      Creates DATE from the LocalDateTime.
      static DATE of​(java.time.LocalTime lt)
      Creates DATE from the LocalTime.
      static DATE of​(java.time.OffsetDateTime odt)
      Creates DATE from the OffsetDateTime.
      static DATE of​(java.time.OffsetTime ot)
      Creates DATE from the OffsetTime.
      static DATE of​(java.time.ZonedDateTime zdt)
      Creates DATE from the ZonedDateTime.
      static byte[] parseFormat​(java.lang.String fmt, java.lang.String lang)
      Converts the fmt string into tokens for use by toText().
      DATE round​(java.lang.String prec)
      returns a DATE object with date rounded to specified precision
      DATE setDayOfWeek​(int day)
      returns a DATE object initialized to date advanced to the week of the day specified.
      java.lang.String stringValue()
      Calls toString to convert internal Oracle DATE to a Java String.
      java.sql.Timestamp timestampValue()
      Calls toTimestamp to convert internal Oracle DATE to a Java Timestamp.
      java.sql.Timestamp timestampValue​(java.util.Calendar cal)
      Calls toTimestamp to convert internal Oracle DATE and Calendar to a Java Timestamp.
      java.sql.Time timeValue()
      Calls toTime to convert internal Oracle DATE to a Java Time.
      java.sql.Time timeValue​(java.util.Calendar cal)
      Calls toTime to convert internal Oracle DATE and Calendar to a Java Time.
      byte[] toBytes()  
      static byte[] toBytes​(java.lang.String str)
      Convert Java String to Oracle DATE.
      static byte[] toBytes​(java.lang.String str, java.util.Calendar cal)
      Convert Java String to Oracle DATE.
      static byte[] toBytes​(java.sql.Date date)
      Convert Java Date to Oracle DATE.
      static byte[] toBytes​(java.sql.Date date, java.util.Calendar cal)
      Convert Java Date and Calendar to Oracle DATE.
      static byte[] toBytes​(java.sql.Time time)
      Convert Java Time to Oracle DATE.
      static byte[] toBytes​(java.sql.Time time, java.util.Calendar cal)
      Convert Java Time and Calendar to Oracle DATE.
      static byte[] toBytes​(java.sql.Timestamp timestamp)
      Convert Java Timestamp to Oracle DATE.
      static byte[] toBytes​(java.sql.Timestamp timestamp, java.util.Calendar cal)
      Convert Java Timestamp and Calendar to Oracle DATE.
      static byte[] toBytes​(java.time.LocalDate ld)
      Convert Java LocalDate to Oracle DATE
      static byte[] toBytes​(java.time.LocalDateTime ldt)
      Convert Java LocalDateTime to Oracle DATE
      static byte[] toBytes​(java.time.LocalTime lt)
      Convert Java LocalTime to Oracle DATE
      static byte[] toBytes​(java.time.OffsetDateTime odt)
      Convert Java OffsetDateTime to Oracle DATE
      static byte[] toBytes​(java.time.OffsetTime ot)
      Convert Java OffsetTime to Oracle DATE
      static byte[] toBytes​(java.time.ZonedDateTime zdt)
      Convert Java ZonedDateTime to Oracle DATE
      static java.sql.Date toDate​(byte[] date)
      Convert Oracle DATE to Java Date.
      static java.sql.Date toDate​(byte[] date, java.util.Calendar cal)
      Convert Oracle DATE and Calendar to Java Date.
      java.lang.Object toJdbc()
      Returns the JDBC representation of the datum object
      void toJulianDays​(int[] julianDay, int[] julianSec)
      Convert to Julian days and seconds from the given date.
      java.time.LocalDate toLocalDate()
      Converts DATE to LocalDate.
      static java.time.LocalDate toLocalDate​(byte[] date)
      Convert a byte array representing a DATE object to a Java LocalDate
      java.time.LocalDateTime toLocalDateTime()
      Converts DATE to LocalDateTime.
      static java.time.LocalDateTime toLocalDateTime​(byte[] date)
      Convert a byte array representing a DATE object to a Java LocalDateTime
      java.time.LocalTime toLocalTime()
      Converts DATE to LocalTime.
      static java.time.LocalTime toLocalTime​(byte[] date)
      Convert a byte array representing a DATE object to a Java LocalTime
      NUMBER toNumber()
      Converts date to an Oracle Number.
      java.lang.String toString()  
      static java.lang.String toString​(byte[] bytes)
      Converts a DATE to a string
      java.lang.String toText​(byte[] pfmt, java.lang.String lang)
      Convert date to text as specified by fmt.
      java.lang.String toText​(java.lang.String fmt, java.lang.String lang)
      Convert date to text as specified by fmt.
      static java.sql.Time toTime​(byte[] date)
      Convert Oracle DATE to Java Time.
      static java.sql.Time toTime​(byte[] date, java.util.Calendar cal)
      Convert Oracle DATE and Calendar to Java Time.
      static java.sql.Timestamp toTimestamp​(byte[] date)
      Convert Oracle DATE to Java Timestamp.
      static java.sql.Timestamp toTimestamp​(byte[] date, java.util.Calendar cal)
      Convert Oracle DATE and Calendar to Java Timestamp.
      DATE truncate​(java.lang.String prec)
      returns a DATE object with date truncated to specified precision
      DATE zeroTime()
      Zero out the time from a DATE object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DATE

        public DATE()
        Constructs a DATE object initialized to 1/1/1970.
      • DATE

        public DATE​(byte[] date)
        Create a DATE object represented by the given Oracle Date.
        Parameters:
        date - Oracle DATE
      • DATE

        public DATE​(java.sql.Date date)
        Create a DATE object given a Java Date object.
        Parameters:
        date - Java Date object
      • DATE

        public DATE​(java.sql.Time time)
        Create a DATE object given a Java Time object.
        Parameters:
        time - Java Time object
      • DATE

        public DATE​(java.sql.Timestamp timestamp)
        Create a DATE object given a Java Timestamp object
        Parameters:
        timestamp - Java Timestamp object
      • DATE

        public DATE​(java.sql.Date date,
                    java.util.Calendar cal)
        Create a DATE object given a Java Date object and a Calendar
        Parameters:
        date - Java Date object
        cal - Java Calendar object which encapsulates the timezone information of date
      • DATE

        public DATE​(java.sql.Time time,
                    java.util.Calendar cal)
        Create a DATE object given a Java Time object and a Calendar
        Parameters:
        time - Java Time object
        cal - Java Calendar object which encapsulates the timezone information of time
      • DATE

        public DATE​(java.sql.Timestamp timestamp,
                    java.util.Calendar cal)
        Create a DATE object given a Java Timestamp object and a Calendar
        Parameters:
        timestamp - Java Timestamp object
        cal - Java Calendar object which encapsulates the timezone information of timestamp
      • DATE

        public DATE​(java.lang.String str)
        Create a DATE object given a Java String object.
        Parameters:
        str - Java String object
      • DATE

        public DATE​(java.lang.String str,
                    boolean lenient)
             throws java.text.ParseException
        Create a DATE object given a Java String object.
        Parameters:
        str - Java String object
        lenient - Java Boolean variable
        Throws:
        java.text.ParseException
      • DATE

        public DATE​(java.lang.String str,
                    java.util.Calendar cal)
        Create a DATE object given a Java String object and a Calendar
        Parameters:
        str - Java String object
        cal - Java Calendar object which encapsulates the timezone information for interpreting str
      • DATE

        public DATE​(java.lang.Object obj)
             throws java.sql.SQLException
        Constructs a DATE object initialized to the value specified by the object
        Parameters:
        obj - Object value
        obj - Object value
        obj - Object value
        Throws:
        java.sql.SQLException - if initialization is not allowed
      • DATE

        public DATE​(java.lang.Object obj,
                    java.util.Calendar cal)
             throws java.sql.SQLException
        Constructs a DATE object initialized to the value specified by the object and a Calendar
        Parameters:
        obj - Object value
        cal - Calendar to use
        obj - Object value
        obj - Object value
        cal - Calendar which encapsulates the timezone information of obj
        Throws:
        java.sql.SQLException - if initialization is not allowed
      • DATE

        public DATE​(java.time.LocalDate ld)
             throws java.sql.SQLException
        Create a DATE object given a Java LocalDate object
        Parameters:
        ld - Java LocalDate object
        Throws:
        java.sql.SQLException
      • DATE

        public DATE​(java.time.LocalDateTime ldt)
             throws java.sql.SQLException
        Create a DATE object given a Java LocalDateTime object
        Parameters:
        ldt - Java LocalDateTime object
        Throws:
        java.sql.SQLException
      • DATE

        public DATE​(java.time.LocalTime lt)
             throws java.sql.SQLException
        Create a DATE object given a Java LocalTime object
        Parameters:
        lt - Java LocalTime object
        Throws:
        java.sql.SQLException
      • DATE

        public DATE​(java.time.OffsetDateTime odt)
             throws java.sql.SQLException
        Create a DATE object given a Java OffsetDateTime object
        Parameters:
        odt - Java OffsetDateTime object
        Throws:
        java.sql.SQLException
      • DATE

        public DATE​(java.time.OffsetTime ot)
             throws java.sql.SQLException
        Create a DATE object given a Java OffsetTime object
        Parameters:
        ot - Java OffsetDateTime object
        Throws:
        java.sql.SQLException
      • DATE

        public DATE​(java.time.ZonedDateTime zdt)
             throws java.sql.SQLException
        Create a DATE object given a Java ZonedDateTime object
        Parameters:
        zdt - Java ZonedDateTime object
        Throws:
        java.sql.SQLException
    • Method Detail

      • toDate

        public static java.sql.Date toDate​(byte[] date)
        Convert Oracle DATE to Java Date.
        Parameters:
        date - Oracle DATE to be converted
        Returns:
        the java.sql.Date object represented by the Oracle DATE date.
      • toTime

        public static java.sql.Time toTime​(byte[] date)
        Convert Oracle DATE to Java Time.
        Parameters:
        date - Oracle DATE to be converted
        Returns:
        the java.sql.Time object represented by the Oracle DATE date.
      • toTimestamp

        public static java.sql.Timestamp toTimestamp​(byte[] date)
        Convert Oracle DATE to Java Timestamp.
        Parameters:
        date - Oracle DATE to be converted
        Returns:
        the java.sql.Timestamp object represented by the Oracle DATE date.
      • toDate

        public static java.sql.Date toDate​(byte[] date,
                                           java.util.Calendar cal)
        Convert Oracle DATE and Calendar to Java Date.
        Parameters:
        date - Oracle DATE to be converted
        cal - Calendar which encapsulates the timezone information to be used to create Date object
        Returns:
        the java.sql.Date object represented by the Oracle DATE date.
      • toTime

        public static java.sql.Time toTime​(byte[] date,
                                           java.util.Calendar cal)
        Convert Oracle DATE and Calendar to Java Time.
        Parameters:
        date - Oracle DATE to be converted
        cal - Calendar which encapsulates the timezone information to be used to create the Time object
        Returns:
        the java.sql.Time object represented by the Oracle DATE date.
      • toTimestamp

        public static java.sql.Timestamp toTimestamp​(byte[] date,
                                                     java.util.Calendar cal)
        Convert Oracle DATE and Calendar to Java Timestamp.
        Parameters:
        date - Oracle DATE to be converted
        cal - Calendar which encapsulates the timezone information to be used to create the Timestamp object
        Returns:
        the java.sql.Timestamp object represented by the Oracle DATE date.
      • toString

        public static java.lang.String toString​(byte[] bytes)
        Converts a DATE to a string
        Parameters:
        date - a byte array
        Returns:
        String representing the date
      • toBytes

        public byte[] toBytes()
        Specified by:
        toBytes in interface oracle.jdbc.internal.OracleDate
      • toBytes

        public static byte[] toBytes​(java.sql.Date date)
        Convert Java Date to Oracle DATE.
        Parameters:
        date - java.sql.Date object to be converted.
        Returns:
        the byte array representing the input date.
      • toBytes

        public static byte[] toBytes​(java.sql.Time time)
        Convert Java Time to Oracle DATE.
        Parameters:
        time - java.sql.Time object to be converted.
        Returns:
        the byte array representing the input time.
      • toBytes

        public static byte[] toBytes​(java.sql.Timestamp timestamp)
        Convert Java Timestamp to Oracle DATE.
        Parameters:
        timestamp - java.sql.Timestamp object to be converted.
        Returns:
        the byte array representing the input timestamp.
      • toBytes

        public static byte[] toBytes​(java.sql.Date date,
                                     java.util.Calendar cal)
        Convert Java Date and Calendar to Oracle DATE.
        Parameters:
        date - java.sql.Date object to be converted.
        cal - java.util.Calendar object which encapsulates the timezone information of date
        Returns:
        the byte array representing the input date.
      • toBytes

        public static byte[] toBytes​(java.sql.Time time,
                                     java.util.Calendar cal)
        Convert Java Time and Calendar to Oracle DATE.
        Parameters:
        time - java.sql.Time object to be converted.
        cal - java.util.Calendar object which encapsulates the timezone information of time
        Returns:
        the byte array representing the input time.
      • toBytes

        public static byte[] toBytes​(java.sql.Timestamp timestamp,
                                     java.util.Calendar cal)
        Convert Java Timestamp and Calendar to Oracle DATE.
        Parameters:
        timestamp - java.sql.Timestamp object to be converted.
        cal - java.util.Calendar object which encapsulates the timezone information of date
        Returns:
        the byte array representing the input timestamp.
      • toBytes

        public static byte[] toBytes​(java.lang.String str)
        Convert Java String to Oracle DATE.
        Parameters:
        str - java.lang.String object to be converted.
        Returns:
        the byte array representing the input string.
      • toBytes

        public static byte[] toBytes​(java.lang.String str,
                                     java.util.Calendar cal)
        Convert Java String to Oracle DATE.
        Parameters:
        str - java.lang.String object to be converted.
        cal - java.util.Calendar object which encapsulates the timezone information for interpreting str
        Returns:
        the byte array representing the input string.
      • dateValue

        public java.sql.Date dateValue()
        Calls toDate to convert internal Oracle DATE to a Java Date.
        Overrides:
        dateValue in class Datum
        Returns:
        a Java Date value
      • timeValue

        public java.sql.Time timeValue()
        Calls toTime to convert internal Oracle DATE to a Java Time.
        Overrides:
        timeValue in class Datum
        Returns:
        a Java Time value
      • timestampValue

        public java.sql.Timestamp timestampValue()
        Calls toTimestamp to convert internal Oracle DATE to a Java Timestamp.
        Overrides:
        timestampValue in class Datum
        Returns:
        a Java Timestamp value
      • dateValue

        public java.sql.Date dateValue​(java.util.Calendar cal)
        Calls toDate to convert internal Oracle DATE and Calendar to a Java Date.
        Parameters:
        cal - Calendar to use
        Returns:
        a Java Date value
      • timeValue

        public java.sql.Time timeValue​(java.util.Calendar cal)
        Calls toTime to convert internal Oracle DATE and Calendar to a Java Time.
        Overrides:
        timeValue in class Datum
        Parameters:
        cal - Calendar to use
        Returns:
        a Java Time value
      • timestampValue

        public java.sql.Timestamp timestampValue​(java.util.Calendar cal)
        Calls toTimestamp to convert internal Oracle DATE and Calendar to a Java Timestamp.
        Overrides:
        timestampValue in class Datum
        Parameters:
        cal - Calendar to use
        Returns:
        a Java Timestamp value
      • stringValue

        public java.lang.String stringValue()
        Calls toString to convert internal Oracle DATE to a Java String.
        Overrides:
        stringValue in class Datum
        Returns:
        a Java String value
      • toString

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

        public java.lang.Object toJdbc()
        Returns the JDBC representation of the datum object
        Specified by:
        toJdbc in class Datum
        Returns:
        an object containing the JDBC value
      • makeJdbcArray

        public java.lang.Object makeJdbcArray​(int arraySize)
        Returns a JDBC array representation of the datum
        Specified by:
        makeJdbcArray in class Datum
        Parameters:
        arraySize - size of the array
        Returns:
        an object containing the JDBC array value
      • isConvertibleTo

        public boolean isConvertibleTo​(java.lang.Class<?> cls)
        Determines if the object can be converted to a particular class
        Specified by:
        isConvertibleTo in class Datum
        Parameters:
        cls - Class to convert to
        Returns:
        true, if conversion to cls is permitted false, if conversion to cls is not permitted
      • addJulianDays

        public DATE addJulianDays​(int julianDay,
                                  int julianSec)
                           throws java.sql.SQLException
        Add Julian days to a date.
        Parameters:
        julianDay - Number of Julian days to add to DATE
        julianSec - Number of seconds past midnight
        Returns:
        new DATE object initalized to the DATE values added to the Julian days.
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • addMonths

        public DATE addMonths​(int months)
                       throws java.sql.SQLException
        Add months to a date.
        Parameters:
        months - integral months to add to date
        Returns:
        new DATE object initialized to the DATE value added to months. months can be negative to perform month subtraction.
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • zeroTime

        public DATE zeroTime()
                      throws java.sql.SQLException
        Zero out the time from a DATE object.
        Throws:
        java.sql.SQLException
      • diffInJulianDays

        public void diffInJulianDays​(DATE date,
                                     int[] julianDay,
                                     int[] julianSec)
                              throws java.sql.SQLException
        Calculates the difference between two dates in Julian days.
        Parameters:
        date - Date to be subtracted.
        julianDay - Number of Julian days
        julianSec - Number of seconds past midnight
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • diffInMonths

        public NUMBER diffInMonths​(DATE date)
                            throws java.sql.SQLException
        Calculates the difference between two dates in months.
        Parameters:
        date - Date to be subtracted.
        Returns:
        NUMBER difference in months as an Oracle Number.
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • getCurrentDate

        public static DATE getCurrentDate()
                                   throws java.sql.SQLException
        Gets current date and time
        Returns:
        DATE object
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • checkValidity

        public static int checkValidity​(byte[] date)
                                 throws java.sql.SQLException
        Checks the DATE passed in.
        Parameters:
        date - Date to be checked
        Returns:
        0 if the date is valid or the ORed representations in the following table:
        BDA Bad day: above range
        BDAL Bad day: below range
        BMO Bad month: above range
        BMOL Bad month: below range
        BYR Bad year: above range
        BYRL Bad year: below range
        BHR Bad hour: above range
        BHRL Bad hour: below range
        BMN Bad minute: above range
        BMNL Bad minute: below range
        BSC Bad second: above range
        BSCL Bad second: below range
        MSD Day is one of those "missing" from the year 1582
        YR0 Year zero does not exist
        BDT Bad date format
        HRZERO Zero valued hour
        MIZERO Zero valued minute
        SEZERO Zero valued second
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • fromJulianDays

        public static DATE fromJulianDays​(int julianDay,
                                          int julianSec)
                                   throws java.sql.SQLException
        Convert given julian days and seconds to an Oracle Date.
        Parameters:
        julianDay - Number of Julian days
        julianSec - Number of seconds past midnight
        Returns:
        new DATE object initialized based on the number of Julian days.
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • fromText

        public static DATE fromText​(java.lang.String datestr,
                                    java.lang.String fmt,
                                    java.lang.String lang)
                             throws java.sql.SQLException
        Convert a string to a DATE object.
        Parameters:
        datestr - Input Date string
        fmt - Date Format
        lang - Input date language
        Returns:
        DATE object Note: Some of the extended Date Formats supported by the C Date libraries from CORE are not supported in this pure Java equivalent implementation. The Format strings supported are:
        String Meaning
        a.d. B.C./A.D. indicator
        a.m. A.M./P.M. indicator
        ad BC/AD indicator
        am AM/PM indicator
        b.c. B.C./A.D. indicator
        bc BC/AD indicator
        d day of the week
        day name of the day, spelled out
        dd day of the month
        ddd day of year
        dy name of weekday abbreviated
        hh hour representation in 12 hour format
        hh24 hour representation in 24 hour format
        mi minutes
        mm two digit month representation
        mon month abbreviation
        month name of the month, spelled out
        p.m. A.M./P.M. indicator
        pm AM/PM indicator
        ss two digit second representation
        Y last digit of the year
        YY last two digits of a year
        YYY last three digits of a year
        YYYY year
        "" all text in quotes is copied into the output string It is not possible to place a quote character into the output string. On input, literal text is a placeholder for another string of the same length
        /,%&@#.. punctuation (non-alphanumeric characters) is treated exactly like a literal without the need for quotes.

        The Date format string not supported versus the C library are:

        String Meaning
        E abbreviated era name
        EE full era name
        FX all date literals must be an exact match
        j Julian day
        RM Roman numeral month (I-XII)
        RR Round year with two digits (on input, rounds the century up one if the year is <50 and the reference date is >= 50, and down one century if the year is >= 50 and the reference date is <50)
        RRRR Round year (on input, accepts either four digit input or, for two digit input, rounds the century up one if the year is <50 and the reference date is >= 50, and down one century if the year is >= 50 and the reference date is <50)
        sssss number of seconds past midnight
        sy,yyy signed year (BC dates have "-" in front)
        syYYY signed year (BC dates have "-" in front)
        Y,YYY year with comma
        YEAR year number spelled out

        Also parsing is strict i.e. spaces and literals should match the format string exactly. (except for a.d./b.c. the string should be ad/bc)

        Throws:
        java.sql.SQLException
      • lastDayOfMonth

        public DATE lastDayOfMonth()
                            throws java.sql.SQLException
        returns a DATE object intialized to the last day of the month .
        Returns:
        a DATE object
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • numberToJulianDays

        public static void numberToJulianDays​(NUMBER num,
                                              int[] julianDay,
                                              int[] julianSec)
                                       throws java.sql.SQLException
        Converts an Oracle NUMBER to Julian days and seconds
        Parameters:
        num - Oracle Number to convert
        julianDay - Number of Julian days
        julianSec - Number of seconds past midnight
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • round

        public DATE round​(java.lang.String prec)
                   throws java.sql.SQLException
        returns a DATE object with date rounded to specified precision
        Parameters:
        prec - precision to use while rounding
        Returns:
        DATE object
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • setDayOfWeek

        public DATE setDayOfWeek​(int day)
                          throws java.sql.SQLException
        returns a DATE object initialized to date advanced to the week of the day specified.
        Parameters:
        day - day of the week the date needs to be advanced
        Returns:
        DATE object.
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • toJulianDays

        public void toJulianDays​(int[] julianDay,
                                 int[] julianSec)
                          throws java.sql.SQLException
        Convert to Julian days and seconds from the given date.
        Parameters:
        julianDay - Number of Julian days
        julianSec - Number of seconds past midnight
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • toNumber

        public NUMBER toNumber()
                        throws java.sql.SQLException
        Converts date to an Oracle Number.
        Returns:
        an Oracle Number
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • toText

        public java.lang.String toText​(java.lang.String fmt,
                                       java.lang.String lang)
                                throws java.sql.SQLException
        Convert date to text as specified by fmt.
        Parameters:
        fmt - date format
        lang - the NLS language the conversion is to be performed in, null indicates use default.
        Returns:
        a String converted from date via format fmt.
        Throws:
        java.sql.SQLException - if Java implementation is not available or an invalid format string is provided.
      • toText

        public java.lang.String toText​(byte[] pfmt,
                                       java.lang.String lang)
                                throws java.sql.SQLException
        Convert date to text as specified by fmt.
        Parameters:
        pfmt - date format parsed by parseFormat
        lang - the NLS language the conversion is to be performed in, null indicates use default.
        Returns:
        a String converted from date via format fmt.
        Throws:
        java.sql.SQLException - if Java implementation is not available or an invalid format string is provided.
      • parseFormat

        public static byte[] parseFormat​(java.lang.String fmt,
                                         java.lang.String lang)
                                  throws java.sql.SQLException
        Converts the fmt string into tokens for use by toText().
        Parameters:
        fmt - date format
        lang - A String containing NLS Language and/or Territory null indicates to use default.
        Returns:
        a byte array containing tokens from the parsed format
        Throws:
        java.sql.SQLException - if the format string can not be parsed.
      • truncate

        public DATE truncate​(java.lang.String prec)
                      throws java.sql.SQLException
        returns a DATE object with date truncated to specified precision
        Parameters:
        prec - precision to use while truncating
        Returns:
        DATE object
        Throws:
        java.sql.SQLException - if Java implementation is not available
      • compareTo

        public int compareTo​(DATE date)
        Returns -1 if DATE is less than date, 0 if DATE and date are equal (==), 1 if DATE is greater than date.
        Parameters:
        date - input Oracle Date
        Returns:
        integer result of comparison
      • of

        public static DATE of​(java.time.LocalDate ld)
                       throws java.sql.SQLException
        Creates DATE from the LocalDate.
        Parameters:
        ld - LocalDate object
        Returns:
        DATE object
        Throws:
        java.sql.SQLException
      • toLocalDate

        public java.time.LocalDate toLocalDate()
                                        throws java.sql.SQLException
        Converts DATE to LocalDate.
        Returns:
        LocalDate object.
        Throws:
        java.sql.SQLException
      • localDateValue

        public java.time.LocalDate localDateValue()
                                           throws java.sql.SQLException
        Converts DATE to LocalDate.
        Returns:
        LocalDate object.
        Throws:
        java.sql.SQLException
      • of

        public static DATE of​(java.time.LocalDateTime ldt)
                       throws java.sql.SQLException
        Creates DATE from the LocalDateTime.
        Parameters:
        ldt - LocalDateTime object
        Returns:
        DATE object
        Throws:
        java.sql.SQLException
      • toLocalDateTime

        public java.time.LocalDateTime toLocalDateTime()
                                                throws java.sql.SQLException
        Converts DATE to LocalDateTime.
        Returns:
        LocalDateTime object.
        Throws:
        java.sql.SQLException
      • localDateTimeValue

        public java.time.LocalDateTime localDateTimeValue()
                                                   throws java.sql.SQLException
        Converts DATE to LocalDateTime.
        Returns:
        LocalDateTime object.
        Throws:
        java.sql.SQLException
      • of

        public static DATE of​(java.time.LocalTime lt)
                       throws java.sql.SQLException
        Creates DATE from the LocalTime.
        Parameters:
        lt - LocalTime object
        Returns:
        DATE object
        Throws:
        java.sql.SQLException
      • toLocalTime

        public java.time.LocalTime toLocalTime()
                                        throws java.sql.SQLException
        Converts DATE to LocalTime.
        Returns:
        LocalTime object.
        Throws:
        java.sql.SQLException
      • localTimeValue

        public java.time.LocalTime localTimeValue()
                                           throws java.sql.SQLException
        Converts DATE to LocalTime.
        Returns:
        LocalTime object.
        Throws:
        java.sql.SQLException
      • of

        public static DATE of​(java.time.OffsetDateTime odt)
                       throws java.sql.SQLException
        Creates DATE from the OffsetDateTime.
        Parameters:
        odt - OffsetDateTime object
        Returns:
        DATE object
        Throws:
        java.sql.SQLException
      • of

        public static DATE of​(java.time.OffsetTime ot)
                       throws java.sql.SQLException
        Creates DATE from the OffsetTime.
        Parameters:
        ot - OffsetTime object
        Returns:
        DATE object
        Throws:
        java.sql.SQLException
      • of

        public static DATE of​(java.time.ZonedDateTime zdt)
                       throws java.sql.SQLException
        Creates DATE from the ZonedDateTime.
        Parameters:
        zdt - ZonedDateTime object
        Returns:
        DATE object
        Throws:
        java.sql.SQLException
      • toLocalDate

        public static java.time.LocalDate toLocalDate​(byte[] date)
                                               throws java.sql.SQLException
        Convert a byte array representing a DATE object to a Java LocalDate
        Parameters:
        date - Oracle DATE object to be converted
        Returns:
        the java.time.LocalDate object represented by the Oracle DATE object.
        Throws:
        java.sql.SQLException
      • toLocalTime

        public static java.time.LocalTime toLocalTime​(byte[] date)
                                               throws java.sql.SQLException
        Convert a byte array representing a DATE object to a Java LocalTime
        Parameters:
        date - Oracle DATE object to be converted
        Returns:
        the java.time.LocalTime object represented by the Oracle DATE object.
        Throws:
        java.sql.SQLException
      • toLocalDateTime

        public static java.time.LocalDateTime toLocalDateTime​(byte[] date)
                                                       throws java.sql.SQLException
        Convert a byte array representing a DATE object to a Java LocalDateTime
        Parameters:
        date - Oracle DATE object to be converted
        Returns:
        the java.time.LocalDateTime object represented by the Oracle DATE object.
        Throws:
        java.sql.SQLException
      • toBytes

        public static byte[] toBytes​(java.time.LocalDate ld)
        Convert Java LocalDate to Oracle DATE
        Parameters:
        ld - LocalDate object
        Returns:
        the byte array representing the java LocalDate.
      • toBytes

        public static byte[] toBytes​(java.time.LocalDateTime ldt)
        Convert Java LocalDateTime to Oracle DATE
        Parameters:
        ldt - LocalDateTime object
        Returns:
        the byte array representing the java LocalDateTime.
      • toBytes

        public static byte[] toBytes​(java.time.LocalTime lt)
        Convert Java LocalTime to Oracle DATE
        Parameters:
        lt - LocalTime object
        Returns:
        the byte array representing the java LocalTime.
      • toBytes

        public static byte[] toBytes​(java.time.OffsetDateTime odt)
        Convert Java OffsetDateTime to Oracle DATE
        Parameters:
        odt - OffsetDateTime object
        Returns:
        the byte array representing the java OffsetDateTime.
      • toBytes

        public static byte[] toBytes​(java.time.OffsetTime ot)
        Convert Java OffsetTime to Oracle DATE
        Parameters:
        ot - OffsetTime object
        Returns:
        the byte array representing the java OffsetTime.
      • toBytes

        public static byte[] toBytes​(java.time.ZonedDateTime zdt)
        Convert Java ZonedDateTime to Oracle DATE
        Parameters:
        zdt - ZonedDateTime object
        Returns:
        the byte array representing the java ZonedDateTime.