Oracle10g JDBC

oracle.sql
Class TIMESTAMP

java.lang.Object
  extended byoracle.sql.Datum
      extended byoracle.sql.TIMESTAMP

public class TIMESTAMP
extends Datum

TIMESTAMP Class


The TIMESTAMP 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 eleven byte array in the super class' storage area. The bytes are arranged as follows:

      Byte       Represents
       0         Century (119 for 1990)
       1         Decade  (190 for 1990)
       2         Month
       3         Day      
       4         Hour
       5         Minute
       6         Seconds
       7         Nanoseconds
       8         Nanoseconds
       9         Nanoseconds
       10        Nanoseconds
  

Static methods are used for conversions.

Since:
release specific (what release of product did this appear in)

Constructor Summary
TIMESTAMP()
          Constructs a TIMESTAMP object initialized to 1/1/1970.
TIMESTAMP(byte[] timestamp)
          Create an Oracle TIMESTAMP object represented by the given Oracle Timestamp
TIMESTAMP(java.sql.Date date)
          Create an Oracle TIMESTAMP object represented by the java Date
TIMESTAMP(DATE date)
          Create an Oracle TIMESTAMP object represented by the Oracle date
TIMESTAMP(java.lang.String str)
          Create a TIMESTAMP object given a Java String object.
TIMESTAMP(java.sql.Time time)
          Create an Oracle TIMESTAMP object represented by the given java Time
TIMESTAMP(java.sql.Timestamp timestamp)
          Create an Oracle TIMESTAMP object represented by the java Timestamp
 
Method Summary
 boolean isConvertibleTo(java.lang.Class cls)
          Determines if the object can be converted to a particular class
 java.lang.Object makeJdbcArray(int arraySize)
          Returns a JDBC array representation of the datum
 java.lang.String stringValue()
          Calls toString to convert internal Oracle TIMESTAMP to a Java String.
 java.sql.Timestamp timestampValue()
          Calls toTimestamp to convert internal Oracle Date to a Java Timestamp.
static TIMESTAMP TimeZoneConvert(java.sql.Connection conn, TIMESTAMP tstamp, java.util.TimeZone tz1, java.util.TimeZone tz2)
          Converts the TIMESTAMP object from one timezone to the other
 byte[] toBytes()
          Convert Oracle Timestamp object into a byte array
static byte[] toBytes(java.sql.Date date)
          Convert Java Date to Oracle TIMESTAMP.
static byte[] toBytes(DATE date)
          Convert Oracle DATE to Oracle Timestamp
static byte[] toBytes(java.lang.String str)
          Convert Java String to Oracle TIMESTAMP.
static byte[] toBytes(java.sql.Time time)
          Convert Java Time to Oracle TIMESTAMP.
static byte[] toBytes(java.sql.Timestamp timestamp)
          Convert Java Timestamp to Oracle Timestamp
static java.sql.Date toDate(byte[] timestamp)
          Convert a byte array representing a TIMESTAMP object to a Java Date Object
static DATE toDATE(byte[] timestamp)
          Convert a byte array representing a TIMESTAMP object to a Oracle Date Object
 java.lang.Object toJdbc()
          Returns the JDBC representation of the datum object
static java.lang.String toString(byte[] timestamp)
          Converts a TIMESTAMP to a string
static java.sql.Time toTime(byte[] timestamp)
          Convert a byte array representing a TIMESTAMP object to a Java Time Object
static java.sql.Timestamp toTimestamp(byte[] timestamp)
          Convert a byte array representing a TIMESTAMP object to a Java Timestamp Object
 
Methods inherited from class oracle.sql.Datum
asciiStreamValue, bigDecimalValue, binaryStreamValue, booleanValue, byteValue, characterStreamValue, dateValue, doubleValue, equals, floatValue, getBytes, getLength, getStream, intValue, longValue, setBytes, setShareBytes, shareBytes, timeValue
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TIMESTAMP

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


TIMESTAMP

public TIMESTAMP(byte[] timestamp)
Create an Oracle TIMESTAMP object represented by the given Oracle Timestamp

Parameters:
timestamp - Oracle TIMESTAMP

TIMESTAMP

public TIMESTAMP(java.sql.Time time)
Create an Oracle TIMESTAMP object represented by the given java Time

Parameters:
time - Java Time object

TIMESTAMP

public TIMESTAMP(java.sql.Date date)
Create an Oracle TIMESTAMP object represented by the java Date

Parameters:
date - Java Date object

TIMESTAMP

public TIMESTAMP(java.sql.Timestamp timestamp)
Create an Oracle TIMESTAMP object represented by the java Timestamp

Parameters:
timestamp - Java Timestamp object

TIMESTAMP

public TIMESTAMP(DATE date)
Create an Oracle TIMESTAMP object represented by the Oracle date

Parameters:
date - Oracle DATE object

TIMESTAMP

public TIMESTAMP(java.lang.String str)
Create a TIMESTAMP object given a Java String object.

Parameters:
str - Java String object
Method Detail

toDate

public static java.sql.Date toDate(byte[] timestamp)
                            throws java.sql.SQLException
Convert a byte array representing a TIMESTAMP object to a Java Date Object

Throws:
java.sql.SQLException

toTime

public static java.sql.Time toTime(byte[] timestamp)
                            throws java.sql.SQLException
Convert a byte array representing a TIMESTAMP object to a Java Time Object

Throws:
java.sql.SQLException

toTimestamp

public static java.sql.Timestamp toTimestamp(byte[] timestamp)
                                      throws java.sql.SQLException
Convert a byte array representing a TIMESTAMP object to a Java Timestamp Object

Throws:
java.sql.SQLException

toDATE

public static DATE toDATE(byte[] timestamp)
                   throws java.sql.SQLException
Convert a byte array representing a TIMESTAMP object to a Oracle Date Object

Throws:
java.sql.SQLException

timestampValue

public java.sql.Timestamp timestampValue()
                                  throws java.sql.SQLException
Calls toTimestamp to convert internal Oracle Date to a Java Timestamp.

Overrides:
timestampValue in class Datum
Returns:
a Java Timestamp value
Throws:
java.sql.SQLException

toString

public static java.lang.String toString(byte[] timestamp)
Converts a TIMESTAMP to a string

Returns:
String representing the date

toBytes

public byte[] toBytes()
Convert Oracle Timestamp object into a byte array

Returns:
the byte array stored in the TIMESTAMP object

toBytes

public static byte[] toBytes(java.sql.Time time)
Convert Java Time to Oracle TIMESTAMP.

Parameters:
time - java.sql.Time object to be converted.
Returns:
the byte array representing the java Time.

toBytes

public static byte[] toBytes(java.sql.Date date)
Convert Java Date to Oracle TIMESTAMP.

Parameters:
date - java.sql.Date object to be converted.
Returns:
the byte array representing the java Date.

toBytes

public static byte[] toBytes(java.sql.Timestamp timestamp)
Convert Java Timestamp to Oracle Timestamp

Returns:
the byte array representing the java timestamp.

toBytes

public static byte[] toBytes(DATE date)
Convert Oracle DATE to Oracle Timestamp

Parameters:
date - oracle.sql.Timestamp object to be converted.
Returns:
the byte array representing the oracle DATE.

toBytes

public static byte[] toBytes(java.lang.String str)
Convert Java String to Oracle TIMESTAMP.

Parameters:
str - java.lang.String object to be converted.
Returns:
the byte array representing the input string.

toJdbc

public java.lang.Object toJdbc()
                        throws java.sql.SQLException
Returns the JDBC representation of the datum object

Specified by:
toJdbc in class Datum
Returns:
an object containing the JDBC value
Throws:
java.sql.SQLException - if conversion to JDBC representation results in an error

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

TimeZoneConvert

public static TIMESTAMP TimeZoneConvert(java.sql.Connection conn,
                                        TIMESTAMP tstamp,
                                        java.util.TimeZone tz1,
                                        java.util.TimeZone tz2)
                                 throws java.sql.SQLException
Converts the TIMESTAMP object from one timezone to the other

Parameters:
conn - Java Connection object tstamp TIMESTAMP object to be converted tz1 Source timezone tz2 Destination timezone
Returns:
TIMESTAMP object in the destination timezone
Throws:
java.sql.SQLException

stringValue

public java.lang.String stringValue()
Calls toString to convert internal Oracle TIMESTAMP to a Java String.

Overrides:
stringValue in class Datum
Returns:
a Java String value

Oracle10g JDBC

Copyright © 1998,2004, Oracle. All rights reserved