com.informix.lang

Class IntervalDF



  • public class IntervalDF
    extends Interval
    This class represents day-to-fraction INTERVAL SQL data types in Java. This class was created because the Sun JDBC specification did not include such a class.
    See Also:
    Timestamp
    • Constructor Summary

      Constructors 
      Constructor and Description
      IntervalDF()
      Default Constructor with the default qualifier set to: leading field precision: 2 start code: TU_DAY end code: TU_F5
      IntervalDF(java.sql.Connection conn)
      Default Constructor with the default qualifier set to: leading field precision: 2 start code: TU_DAY end code: TU_F5 This constructor allows you to display localized error messages if an exception is thrown.
      IntervalDF(long seconds, long nanos)
      Creates an Interval from a number of seconds and nanoseconds.
      IntervalDF(long seconds, long nanos, java.sql.Connection conn)
      Creates an Interval from a number of seconds and nanoseconds.
      IntervalDF(long seconds, long nanos, short qual)
      Creates an Interval from a number of seconds, number of nanoseconds, and qualifier.
      IntervalDF(long seconds, long nanos, short qual, java.sql.Connection conn)
      Creates an Interval from a number of seconds, number of nanoseconds, and qualifier.
      IntervalDF(java.lang.String str)
      Creates an Interval from a string and the default qualifier is set to: leading field precision: 2 start code: TU_DAY end code: TU_F5
      IntervalDF(java.lang.String str, byte startCode, byte endCode)
      Creates an Interval from a string and qualifier information.
      IntervalDF(java.lang.String str, java.sql.Connection conn)
      Creates an Interval from a string and the default qualifier is set to: leading field precision: 2 start code: TU_DAY end code: TU_F5 This constructor supports localized error messages.
      IntervalDF(java.lang.String str, int len, byte startCode, byte endCode)
      Creates an Interval from a string and qualifier information.
      IntervalDF(java.lang.String str, int len, byte startCode, byte endCode, java.sql.Connection conn)
      Creates an Interval from a string and qualifier information.
      IntervalDF(java.lang.String str, short qual)
      Creates an Interval from a string and the qualifier.
      IntervalDF(java.lang.String str, short qual, java.sql.Connection conn)
      Creates an Interval from a string and the qualifier.
      IntervalDF(java.sql.Timestamp t1, java.sql.Timestamp t2)
      Creates an Interval object from two timestamps.
      IntervalDF(java.sql.Timestamp t1, java.sql.Timestamp t2, java.sql.Connection conn)
      Creates an Interval object from two timestamps.
    • Constructor Detail

      • IntervalDF

        public IntervalDF()
        Default Constructor with the default qualifier set to: leading field precision: 2 start code: TU_DAY end code: TU_F5
      • IntervalDF

        public IntervalDF(java.sql.Connection conn)
        Default Constructor with the default qualifier set to: leading field precision: 2 start code: TU_DAY end code: TU_F5 This constructor allows you to display localized error messages if an exception is thrown.
        Parameters:
        conn - Connection object
      • IntervalDF

        public IntervalDF(java.sql.Timestamp t1,
                          java.sql.Timestamp t2)
        Creates an Interval object from two timestamps. The default qualifier is: leading field precision: 2 start code: TU_DAY end code: TU_F5
        Parameters:
        t1 - First timestamp.
        t2 - Second timestamp.
      • IntervalDF

        public IntervalDF(java.sql.Timestamp t1,
                          java.sql.Timestamp t2,
                          java.sql.Connection conn)
        Creates an Interval object from two timestamps. The default qualifier is: leading field precision: 2 start code: TU_DAY end code: TU_F5 This constructor supports localized error messages.
        Parameters:
        t1 - First timestamp.
        t2 - Second timestamp.
        conn - Connection object.
      • IntervalDF

        public IntervalDF(long seconds,
                          long nanos)
        Creates an Interval from a number of seconds and nanoseconds. The default qualifier is: leading field precision: 2 start code: TU_DAY end code: TU_F5
        Parameters:
        seconds - Number of seconds in the interval.
        nanos - Number of nanoseconds in the interval.
      • IntervalDF

        public IntervalDF(long seconds,
                          long nanos,
                          java.sql.Connection conn)
        Creates an Interval from a number of seconds and nanoseconds. The default qualifier is: leading field precision: 2 start code: TU_DAY end code: TU_F5 This constructor supports localized error messages.
        Parameters:
        seconds - Number of seconds in the interval.
        nanos - Number of nanoseconds in the interval.
        conn - Connection object
      • IntervalDF

        public IntervalDF(long seconds,
                          long nanos,
                          short qual)
                   throws java.sql.SQLException
        Creates an Interval from a number of seconds, number of nanoseconds, and qualifier.
        Parameters:
        seconds - Number of seconds in the interval.
        nanos - Number of nanoseconds in the interval.
        qual - Interval qualifier value.
        Throws:
        java.sql.SQLException - if there is a database access error
      • IntervalDF

        public IntervalDF(long seconds,
                          long nanos,
                          short qual,
                          java.sql.Connection conn)
                   throws java.sql.SQLException
        Creates an Interval from a number of seconds, number of nanoseconds, and qualifier. This constructor supports localized error messages.
        Parameters:
        seconds - Number of seconds in the interval.
        nanos - Number of nanoseconds in the interval.
        qual - Interval qualifier value.
        conn - Connection object
        Throws:
        java.sql.SQLException - if there is a database access error
      • IntervalDF

        public IntervalDF(java.lang.String str)
                   throws java.sql.SQLException
        Creates an Interval from a string and the default qualifier is set to: leading field precision: 2 start code: TU_DAY end code: TU_F5
        Parameters:
        str - String Interval value.
        Throws:
        java.sql.SQLException - if there is a database access error
      • IntervalDF

        public IntervalDF(java.lang.String str,
                          java.sql.Connection conn)
                   throws java.sql.SQLException
        Creates an Interval from a string and the default qualifier is set to: leading field precision: 2 start code: TU_DAY end code: TU_F5 This constructor supports localized error messages.
        Parameters:
        str - String Interval value.
        conn - Connection object
        Throws:
        java.sql.SQLException - if there is a database access error
      • IntervalDF

        public IntervalDF(java.lang.String str,
                          short qual)
                   throws java.sql.SQLException
        Creates an Interval from a string and the qualifier.
        Parameters:
        str - String Interval value.
        qual - Interval qualifier value.
        Throws:
        java.sql.SQLException - if there is a database access error
      • IntervalDF

        public IntervalDF(java.lang.String str,
                          short qual,
                          java.sql.Connection conn)
                   throws java.sql.SQLException
        Creates an Interval from a string and the qualifier. This constructor supports localized error messages.
        Parameters:
        str - String Interval value.
        qual - Interval qualifier value.
        conn - Connection object
        Throws:
        java.sql.SQLException - if there is a database access error
      • IntervalDF

        public IntervalDF(java.lang.String str,
                          int len,
                          byte startCode,
                          byte endCode)
                   throws java.sql.SQLException
        Creates an Interval from a string and qualifier information.
        Parameters:
        str - The string representation of the day to fraction Interval.
        len - The total length of the qualifier fields.
        startCode - The starting time unit value (TU_XXX).
        endCode - The ending time unit value (TU_XXX).
        Throws:
        java.sql.SQLException - if there is a database access error
      • IntervalDF

        public IntervalDF(java.lang.String str,
                          byte startCode,
                          byte endCode)
                   throws java.sql.SQLException
        Creates an Interval from a string and qualifier information. This uses a default 2 byte length for fields
        Parameters:
        str - The string representation of the day to fraction Interval.
        startCode - The starting time unit value (TU_XXX).
        endCode - The ending time unit value (TU_XXX).
        Throws:
        java.sql.SQLException - if there is a database access error
      • IntervalDF

        public IntervalDF(java.lang.String str,
                          int len,
                          byte startCode,
                          byte endCode,
                          java.sql.Connection conn)
                   throws java.sql.SQLException
        Creates an Interval from a string and qualifier information. This constructor supports localized error messages.
        Parameters:
        str - The string representation of the day to fraction Interval.
        len - The total length of the qualifier fields.
        startCode - The starting time unit value (TU_XXX).
        endCode - The ending time unit value (TU_XXX).
        conn - Connection object
        Throws:
        java.sql.SQLException - if there is a database access error
    • Method Detail

      • set

        public void set(java.sql.Timestamp t1,
                        java.sql.Timestamp t2)
        Sets the value of the Interval from the difference between two timestamps.
        Parameters:
        t1 - First timestamp.
        t2 - Second timestamp.
      • set

        public void set(long seconds,
                        long nanos)
        Sets the value of the Interval from specified second and nanosecond values.
        Parameters:
        seconds - Number of seconds in the interval.
        nanos - Number of nanoseconds in the interval.
      • set

        public void set(java.lang.String str)
                 throws java.sql.SQLException
        Sets the value of the Interval from a specified string.
        Parameters:
        str - A valid string representing a day to fraction INTERVAL.
        Throws:
        java.sql.SQLException - if there is a database access error
      • toString

        public java.lang.String toString()
        Creates a string representation of the interval in the following format: ddddd hh:mm:ss.nano The presence of the various fields depends upon the qualifier. If no qualifier has been set, the default is the full format. Any leading zeros in the composed string are replaced by blanks.
        Overrides:
        toString in class java.lang.Object
        Returns:
        ddddd hh:mm:ss.nano
      • fromString

        public void fromString(java.lang.String str)
                        throws java.sql.SQLException
        Sets the values for the Interval from a string. This is done as a separate method rather than using the valueOf() method, since valueOf() is usually a class method, and this method must use the qualifier property.
        Parameters:
        str - String in ddddd hh:mm:ss.nano format.
        Throws:
        java.sql.SQLException - if there is a database access error
      • getSeconds

        public long getSeconds()
        Returns the number of seconds in the Interval.
        Returns:
        The number of seconds.
      • getNanoSeconds

        public long getNanoSeconds()
        Returns the number of nanoseconds in the Interval.
        Returns:
        The number of nanoseconds.
      • equals

        public boolean equals(java.lang.Object obj)
        Overrides:
        equals in class Interval
      • greaterThan

        public boolean greaterThan(IntervalDF other)
        Compares this Interval with another to see if it is greater (longer in time) than the other.
        Parameters:
        other - The Interval to which this Interval is compared.
        Returns:
        True if this Interval is greater, false if not.
      • lessThan

        public boolean lessThan(IntervalDF other)
        Compares this Interval with another to see if it is less (shorter in time) than the other.
        Parameters:
        other - The Interval to which this Interval is compared.
        Returns:
        True if this Interval is less, false if not.
      • setQualifier

        public void setQualifier(byte len,
                                 byte startCode,
                                 byte endCode)
                          throws java.sql.SQLException
        Sets the qualifier from its constituent pieces.
        Parameters:
        len - The total length of the qualifier fields.
        startCode - The starting time unit value (TU_XXX).
        endCode - The ending time unit value (TU_XXX).
        Throws:
        java.sql.SQLException - if there is a database access error
      • setQualifier

        public void setQualifier(short qualifier)
                          throws java.sql.SQLException
        Sets the qualifier using an existing qualifier.
        Parameters:
        qualifier - The qualifier value.
        Throws:
        java.sql.SQLException - if there is a database access error