jet.connect
Class DbTimestamp

java.lang.Object
  extended by jet.connect.DbValue
      extended by jet.connect.DbDateTime
          extended by jet.connect.DbTimestamp
All Implemented Interfaces:
jet.util.DbValueable, jet.util.QuickSortableNode

public class DbTimestamp
extends DbDateTime

A thin wrapper around SQL TIMESTAMP value. It adds the ability to hold the SQL TIMESTAMP fractional seconds value by allowing the specification of fractional seconds to a precision of nanoseconds.

In addition, this class provides several methods for the interconversion of a DbTimestamp and a String, as well as other constants and methods used when dealing with a DbTimestamp.

Note: This type is a composite of a java.util.Date long value and a separate nanoseconds value.


Field Summary
 int nanos
          Deprecated.  
 
Fields inherited from class jet.connect.DbDateTime
value
 
Fields inherited from class jet.connect.DbValue
bNull, CHAR_DESC, CURRENCY_DESC, DATE_DESC, desc, DOUBLE_DESC, INTEGER_DESC, TIME_DESC
 
Fields inherited from interface jet.util.DbValueable
EQUAL, GREATER, LESS
 
Constructor Summary
DbTimestamp()
          Constructs an uninitialized DbTimestamp.
DbTimestamp(DbColDesc desc)
          Constructs an uninitialized DbTimestamp.
DbTimestamp(java.sql.Timestamp v)
          Constructs an uninitialized DbTimestamp.
 
Method Summary
 java.lang.Object clone()
          Creates a clone of this DbTimestamp object.
 int compareTo(DbValue v)
          Compares this DbTimestamp object with the DbValue object.
 boolean equals(DbValue v)
          Compares this object to the specified object.
 int getNanos()
          Returns a nanoseconds time value of this object.
 java.sql.Timestamp getTimestamp()
          Returns a java.sql.Timestamp object using the milliseconds time value and the nanoseconds value.
 void set(DbValue v)
          Sets a newly allocated DbTimestamp object that represents the the long date value and int time value indicated by the DbValue parameter.
 void set(JRHierarchicalDataset hds, int col)
          Sets a newly allocated DbTimestamp object that represents the long date value and int time value indicated by the JRHierarchicalDataset parameter and an index of the column.
 void set(long time, int nanos)
          Sets a DbTimestamp object using a milliseconds time value for date, and a nanoseconds time value for time.
 void set(java.sql.ResultSet rs, int col)
          Sets a newly allocated DbTimestamp object that represents the long date value and int time value indicated by the ResultSet parameter and an index of the column.
 void set(java.sql.Timestamp v)
          Sets an existing java.sql.Timestamp object using the given milliseconds and nanoseconds value.
 void setNanos(int v)
          Sets an existing java.sql.Time object using the given nanoseconds time value.
 void setTimestamp(java.sql.Timestamp v)
          Sets an existing java.sql.Timestamp object using the given milliseconds and nanoseconds value.
 void setValue(java.lang.String v)
          Sets a DbTimestamp value for a String object in JDBC timestamp escape format.
 java.lang.String toFormatString(java.lang.String pattern)
          This method is for parsing DbTimestamp to valid string, which contains nanos.
 java.lang.String toString()
          Returns a String object representing this DbTimestamp's value.
 java.lang.String toStringValue()
           
 java.util.Date toUtilDate()
          Returns a java.util.Date object and initializes it to represent the specified number of milliseconds since the standard base time is known as "the epoch", namely, January 1, 1970, 00:00:00 GMT.
 
Methods inherited from class jet.connect.DbDateTime
get, set, toSqlDate
 
Methods inherited from class jet.connect.DbValue
compareTo, compareTo, equals, getColDesc, getPrecision, getScale, getSqlType, isCurrency, isNull, makeDbValue, setColDesc, setfoo, setNull, setValue
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nanos

public int nanos
Deprecated. 
The field contains the nanoseconds value of this object. Note use getNanos and setNanos to access it instead of accessing it directly.

Constructor Detail

DbTimestamp

public DbTimestamp()
Constructs an uninitialized DbTimestamp. This DbTimestamp object is mutable until the value and the description of the column are set.


DbTimestamp

public DbTimestamp(java.sql.Timestamp v)
Constructs an uninitialized DbTimestamp. This DbTimestamp object is mutable until DbColDesc is set.

Parameters:
v - The value holding a java.sql.Timestamp object.

DbTimestamp

public DbTimestamp(DbColDesc desc)
Constructs an uninitialized DbTimestamp. This DbTimestamp object is mutable until the value set.

Parameters:
desc - The value to be represented by the DbColDesc object.
Method Detail

setNanos

public void setNanos(int v)
Sets an existing java.sql.Time object using the given nanoseconds time value.

Parameters:
v - the nanoseconds time value

getNanos

public int getNanos()
Returns a nanoseconds time value of this object.


toUtilDate

public java.util.Date toUtilDate()
Returns a java.util.Date object and initializes it to represent the specified number of milliseconds since the standard base time is known as "the epoch", namely, January 1, 1970, 00:00:00 GMT.

Overrides:
toUtilDate in class DbDateTime

set

public void set(long time,
                int nanos)
Sets a DbTimestamp object using a milliseconds time value for date, and a nanoseconds time value for time. The long seconds are stored in the underlying date value; the fractional seconds are stored in the nanos field of the DbTimestamp object.

Parameters:
time - Milliseconds since January 1, 1970, 00:00:00 GMT. A negative number is the number of milliseconds before January 1, 1970, 00:00:00 GMT.
nanos - Nanoseconds time value for time.
See Also:
Timestamp

getTimestamp

public java.sql.Timestamp getTimestamp()
Returns a java.sql.Timestamp object using the milliseconds time value and the nanoseconds value.


setTimestamp

public void setTimestamp(java.sql.Timestamp v)
Sets an existing java.sql.Timestamp object using the given milliseconds and nanoseconds value.

Parameters:
v - The valid Timestamp value.

set

public void set(java.sql.Timestamp v)
Sets an existing java.sql.Timestamp object using the given milliseconds and nanoseconds value.

Parameters:
v - The valid Timestamp value.

set

public void set(java.sql.ResultSet rs,
                int col)
         throws java.sql.SQLException
Sets a newly allocated DbTimestamp object that represents the long date value and int time value indicated by the ResultSet parameter and an index of the column.

Specified by:
set in class DbValue
Parameters:
rs - The ResultSet to be fetched.
col - The index of the column.
Throws:
java.sql.SQLException - if the ResultSet does not contain the index.

set

public void set(JRHierarchicalDataset hds,
                int col)
         throws java.sql.SQLException
Sets a newly allocated DbTimestamp object that represents the long date value and int time value indicated by the JRHierarchicalDataset parameter and an index of the column.

Overrides:
set in class DbValue
Parameters:
hds - The JRHierarchicalDataset to be fetched.
col - The index of the column.
Throws:
java.sql.SQLException - if the ResultSet does not contain the index.

toString

public java.lang.String toString()
Returns a String object representing this DbTimestamp's value. The value is returned as a string. If the value is null, it returns "NULL".

Specified by:
toString in class DbValue
Returns:
a string representation of the value of this object.

clone

public java.lang.Object clone()
Creates a clone of this DbTimestamp object.

Specified by:
clone in interface jet.util.DbValueable
Specified by:
clone in class DbValue

equals

public boolean equals(DbValue v)
Compares this object to the specified object. The result is true if and only if the argument is not null but a DbTimestamp object that contains the same the long date value and int time value as this object.

Overrides:
equals in class DbDateTime
Parameters:
v - The DbValue object to be compared with.
Returns:
true if the objects are the same; false otherwise.

compareTo

public int compareTo(DbValue v)
Compares this DbTimestamp object with the DbValue object.

Overrides:
compareTo in class DbDateTime
Returns:
LESS, EQUAL, or GREAT.
See Also:
DbValueable

set

public void set(DbValue v)
Sets a newly allocated DbTimestamp object that represents the the long date value and int time value indicated by the DbValue parameter. The DbValue object will be checked to see if it is null,

Overrides:
set in class DbDateTime
Parameters:
v - The DbValue to be converted to a DbChar. If it is null, the value will not be set.

setValue

public void setValue(java.lang.String v)
Sets a DbTimestamp value for a String object in JDBC timestamp escape format.

Specified by:
setValue in class DbValue
Parameters:
v - Timestamp in the format yyyy-[m]m-[d]d hh:mm:ss[.f...]. The fractional seconds may be omitted. The leading zero for mm and dd may also be omitted.

toFormatString

public java.lang.String toFormatString(java.lang.String pattern)
This method is for parsing DbTimestamp to valid string, which contains nanos.

Overrides:
toFormatString in class DbDateTime
Parameters:
pattern - The string is defined in java.text.SimpleDateFormat.

Examples

The following examples show how date and time patterns are interpreted in the U.S. locale. The given date and time are 2001-07-04 12:08:56, which is the local time in the U.S. Pacific Time time zone.
Date and Time Pattern Result
"yyyy.MM.dd G 'at' HH:mm:ss z" 2001.07.04 AD at 12:08:56 PDT
"EEE, MMM d, ''yy" Wed, Jul 4, '01
"h:mm a" 12:08 PM
"hh 'o''clock' a, zzzz" 12 o'clock PM, Pacific Daylight Time
"K:mm a, z" 0:08 PM, PDT
"yyyyy.MMMMM.dd GGG hh:mm aaa" 02001.July.04 AD 12:08 PM
"EEE, d MMM yyyy HH:mm:ss Z" Wed, 4 Jul 2001 12:08:56 -0700
"yyMMddHHmmssZ" 010704120856-0700
"yyyy-MM-dd'T'HH:mm:ss.SSSZ" 2001-07-04T12:08:56.235-0700
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX" 2001-07-04T12:08:56.235-07:00
"YYYY-'W'ww-u" 2001-W27-3
Returns:
the String that formated according to the pattern
Since:
JReport V8.1
See Also:
DbDateTime

toStringValue

public java.lang.String toStringValue()
Overrides:
toStringValue in class DbDateTime
Returns:
a string which will represent the value in the DbValue(null flag and value). When compare StringValue from DbValues, we always assume that: the two DbValues have same DbColDesc. Two StringValue equals means the original DbValue equals. Does NOT transfer the compareTo(DbValue v) method. Only comparable dbValue implements this methods. String coding uses Base64.