DB2 10.5 for Linux, UNIX, and Windows

DBTimestamp class

The com.ibm.db2.jcc.DBTimestamp class can be used to create timestamp objects with a precision of up to picoseconds and time zone information. This class is primarily for support of the SQL TIMESTAMP WITH TIME ZONE data type, which is supported only by DB2® for z/OS®.

The com.ibm.db2.jcc.DBTimestamp class is a subclass of the java.sql.Timestamp class. Therefore, a com.ibm.db2.jcc.DBTimestamp object can be used with any methods that normally operate on a java.sql.Timestamp object, or take a java.sql.Timestamp object as an argument.

The IBM® Data Server Driver for JDBC and SQLJ returns a DBTimestamp object for all JDBC methods that return timestamp information, such as ResultSet.getTimestamp or CallableStatement.getTimestamp.

DBTimestamp constructor

The following constructor is defined only for the IBM Data Server Driver for JDBC and SQLJ.

DBTimestamp
Formats:
public DBTimestamp(long time,
  java.util.Calendar calendar)
  throws java.sql.SQLException
public DBTimestamp(long time)
  throws java.sql.SQLException
public DBTimestamp(java.sql.Timestamp timestamp)
  throws java.sql.SQLException
public DBTimestamp(java.sql.Timestamp timestamp,
  java.util.Calendar calendar)
  throws java.sql.SQLException

Constructs a DBTimestamp object.

Parameter descriptions:
time
The number of milliseconds since January 1, 1970.
timestamp
A Timestamp value with a precision of up to picoseconds.
calendar
The Calendar value that provides the time zone.

DBTimestamp methods

getPicos
Formats:
public long getPicos()

Returns the fractional seconds component of a DBTimestamp value.

getTimeZone
Formats:
public java.util.TimeZone getTimeZone()

Returns the time zone component of a DBTimestamp value.

setPicos
Format:
public void setPicos(long p)
  throws SQLException

Assigns the given value to the fractional seconds component of a DBTimestamp value.

Parameter descriptions:
p
A value between 0 and 999999999999, inclusive, which is the fractional sections component of a DBTimestamp value.
setTimeZone
Format:
public void setTimeZone(java.util.TimeZone timeZone)
  throws SQLException

Assigns the given value to the time zone component of a DBTimestamp value.

Parameter descriptions:
timeZone
The time zone component of a DBTimestamp value.
valueOfDBString
Format:
public static DBTimestamp valueOfDBString(String s)
  throws java.lang.IllegalArgumentException 

Constructs a DBTimestamp value from the string representation of a timestamp value.

Parameter descriptions:
s
The string representation of a timestamp value. The value must be in one of the following formats:
yyyy-mm-dd.hh.mm.ss[.ffffffffffff]-th:tm
yyyy-mm-dd hh:mm:ss[.ffffffffffff]-th:tm
yyyy-mm-dd.hh.mm.ss[.ffffffffffff]
yyyy-mm-dd hh:mm:ss[.ffffffffffff]
  • yyyy is a year.
  • mm is a month.
  • dd is a day.
  • hh is hours.
  • mm is minutes.
  • ss is seconds.
  • [.ffffffffffff] is one to 12 optional fractions of seconds.
  • th is the hours component of a time zone.
  • tm is the minutes component of a time zone.
toDBString
Format:
public String toDBString(boolean includeTimeZone)

Returns the string representation of a DBTimestamp object.

The returned value has one of the following formats:

yyyy-mm-dd.hh.mm.ss[.ffffffffffff]-th:tm
yyyy-mm-dd.hh.mm.ss[.ffffffffffff]
Parameter description:
includeTimeZone
Specifies whether to include the time zone (-th:tm) in the returned string.