Class SQLTimestamp

java.lang.Object
org.apache.derby.iapi.types.DataType
org.apache.derby.iapi.types.SQLTimestamp
All Implemented Interfaces:
Externalizable, Serializable, Comparable, Formatable, Storable, TypedFormat, DataValueDescriptor, DateTimeDataValue, Orderable

public final class SQLTimestamp extends DataType implements DateTimeDataValue
This contains an instance of a SQL Timestamp object.

SQLTimestamp is stored in 3 ints - an encoded date, an encoded time and nanoseconds encodedDate = 0 indicates a null WSCTimestamp SQLTimestamp is similar to SQLTimestamp, but it does conserves space by not keeping a GregorianCalendar object PERFORMANCE OPTIMIZATION: We only instantiate the value field when required due to the overhead of the Date methods. Thus, use isNull() instead of "value == null" and getTimestamp() instead of using value directly.

See Also:
  • Field Details

    • MAX_FRACTION_DIGITS

      static final int MAX_FRACTION_DIGITS
      See Also:
    • FRACTION_TO_NANO

      static final int FRACTION_TO_NANO
      See Also:
    • ONE_BILLION

      static final int ONE_BILLION
      See Also:
    • encodedDate

      private int encodedDate
    • encodedTime

      private int encodedTime
    • nanos

      private int nanos
    • BASE_MEMORY_USAGE

      private static final int BASE_MEMORY_USAGE
    • DATE_SEPARATOR

      static final char DATE_SEPARATOR
      See Also:
    • DATE_SEPARATORS

      private static final char[] DATE_SEPARATORS
    • IBM_DATE_TIME_SEPARATOR

      private static final char IBM_DATE_TIME_SEPARATOR
      See Also:
    • ODBC_DATE_TIME_SEPARATOR

      private static final char ODBC_DATE_TIME_SEPARATOR
      See Also:
    • DATE_TIME_SEPARATORS

      private static final char[] DATE_TIME_SEPARATORS
    • DATE_TIME_SEPARATORS_OR_END

      private static final char[] DATE_TIME_SEPARATORS_OR_END
    • IBM_TIME_SEPARATOR

      private static final char IBM_TIME_SEPARATOR
      See Also:
    • ODBC_TIME_SEPARATOR

      private static final char ODBC_TIME_SEPARATOR
      See Also:
    • TIME_SEPARATORS

      private static final char[] TIME_SEPARATORS
    • TIME_SEPARATORS_OR_END

      private static final char[] TIME_SEPARATORS_OR_END
    • END_OF_STRING

      private static final char[] END_OF_STRING
  • Constructor Details

    • SQLTimestamp

      public SQLTimestamp()
      no-arg constructor required by Formattable
    • SQLTimestamp

      public SQLTimestamp(Timestamp value, Calendar cal) throws StandardException
      Create a new SQLTimestamp instance that represents the specified Timestamp in the time zone of the given Calendar.
      Parameters:
      value - the Timestamp value to be represented by this instance
      cal - the time zone of the calendar is used to construct the database timestamp value
      Throws:
      StandardException - if an error occurs
    • SQLTimestamp

      public SQLTimestamp(Timestamp value) throws StandardException
      Create a new SQLTimestamp instance that represents the specified Timestamp in the local time zone.
      Parameters:
      value - the Timestamp value to be represented by this instance
      Throws:
      StandardException - if an error occurs
    • SQLTimestamp

      SQLTimestamp(int encodedDate, int encodedTime, int nanos)
    • SQLTimestamp

      public SQLTimestamp(DataValueDescriptor date, DataValueDescriptor time) throws StandardException
      Throws:
      StandardException
    • SQLTimestamp

      public SQLTimestamp(String timestampStr, boolean isJDBCEscape, LocaleFinder localeFinder) throws StandardException
      Construct a timestamp from a string. The allowed formats are:
      1. JDBC escape: yyyy-mm-dd hh:mm:ss[.fffff]
      2. IBM: yyyy-mm-dd-hh.mm.ss[.nnnnnn]
      The format is specified by a parameter to the constructor. Leading zeroes may be omitted from the month, day, and hour part of the timestamp. The microsecond part may be omitted or truncated.
      Throws:
      StandardException
    • SQLTimestamp

      public SQLTimestamp(String timestampStr, boolean isJDBCEscape, LocaleFinder localeFinder, Calendar cal) throws StandardException
      Construct a timestamp from a string. The allowed formats are:
      1. JDBC escape: yyyy-mm-dd hh:mm:ss[.fffff]
      2. IBM: yyyy-mm-dd-hh.mm.ss[.nnnnnn]
      The format is specified by a parameter to the constructor. Leading zeroes may be omitted from the month, day, and hour part of the timestamp. The microsecond part may be omitted or truncated.
      Throws:
      StandardException
  • Method Details