Package oracle.sql
Class TIMESTAMP
java.lang.Object
oracle.sql.Datum
oracle.sql.TIMESTAMP
- All Implemented Interfaces:
Serializable,oracle.jdbc.internal.OracleTimestamp
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)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intFields inherited from class oracle.sql.Datum
ojiOracleDatumWithConnection, targetDatum -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a TIMESTAMP object initialized to 1/1/1970.TIMESTAMP(byte[] timestamp) Create an Oracle TIMESTAMP object represented by the given Oracle TimestampCreate a TIMESTAMP object given a Java String object.Create an Oracle TIMESTAMP object represented by the Java DateCreate an Oracle TIMESTAMP object represented by the given Java TimeCreate an Oracle TIMESTAMP object represented by the Java TimestampCreate an Oracle TIMESTAMP object represented by the Java Timestamp and CalendarCreate a TIMESTAMP object given a Java LocalDateTIMESTAMP(LocalDateTime ldt) Create a TIMESTAMP object given a Java LocalDateTimeCreate a TIMESTAMP object given a Java LocalTimeTIMESTAMP(OffsetDateTime odt) Create a TIMESTAMP object given a Java OffsetDateTimeTIMESTAMP(OffsetTime ot) Create a TIMESTAMP object given a Java OffsetTimeTIMESTAMP(ZonedDateTime zdt) Create a TIMESTAMP object given a Java ZonedDateTimeCreate an Oracle TIMESTAMP object represented by the Oracle DATE -
Method Summary
Modifier and TypeMethodDescriptionCalls toDate to convert internal Oracle TIMESTAMP to a Java Date.static intgetJavaYear(int cent, int decade) static intgetOracleYear(int jYear) static intgetOracleYear(Calendar cal) booleanisConvertibleTo(Class<?> cls) Determines if the object can be converted to a particular classConverts TIMESTAMP to LocalDateTime.Converts TIMESTAMP to LocalDate.Converts TIMESTAMP to LocalTime.makeJdbcArray(int arraySize) Returns a JDBC array representation of the datumstatic TIMESTAMPCreates TIMESTAMP from the LocalDate.static TIMESTAMPof(LocalDateTime ldt) Creates TIMESTAMP from the LocalDateTime.static TIMESTAMPCreates TIMESTAMP from the LocalTime.static TIMESTAMPof(OffsetDateTime odt) Create a TIMESTAMP object given a Java OffsetDateTimestatic TIMESTAMPof(OffsetTime ot) Create a TIMESTAMP object given a Java OffsetTimestatic TIMESTAMPof(ZonedDateTime zdt) Create a TIMESTAMP object given a Java ZonedDateTimeCalls toString to convert internal Oracle TIMESTAMP to a Java String.Calls toTimestamp to convert internal Oracle TIMESTAMP to a Java Timestamp.timestampValue(Calendar cal) Calls toTimestamp to convert internal Oracle TIMESTAMP and Calendar to a Java Timestamp.Calls toTime to convert internal Oracle Date to a Java Time.static TIMESTAMPTimeZoneConvert(Connection conn, TIMESTAMP tstamp, TimeZone tz1, TimeZone tz2) Converts the TIMESTAMP object from one timezone to the otherbyte[]toBytes()Convert Oracle TIMESTAMP object into a byte arraystatic byte[]Convert Java String to Oracle TIMESTAMP.static byte[]Convert Java Date to Oracle TIMESTAMP.static byte[]Convert Java Time to Oracle TIMESTAMP.static byte[]Convert Java Timestamp to Oracle TIMESTAMPstatic byte[]Convert Java Timestamp and Java Calendar to Oracle TIMESTAMPstatic byte[]Convert Java LocalDate to Oracle TIMESTAMPstatic byte[]toBytes(LocalDateTime ldt) Convert Java LocalDateTime to Oracle TIMESTAMPstatic byte[]Convert Java LocalTime to Oracle TIMESTAMPstatic byte[]toBytes(OffsetDateTime odt) Convert Java OffsetDateTime to Oracle TIMESTAMPstatic byte[]toBytes(OffsetTime ot) Convert Java OffsetTime to Oracle TIMESTAMPstatic byte[]toBytes(ZonedDateTime zdt) Convert Java ZonedDateTime to Oracle TIMESTAMPstatic byte[]Convert Oracle DATE to Oracle TIMESTAMPstatic DatetoDate(byte[] timestamp) Convert a byte array representing a TIMESTAMP object to a Java Date Objectstatic DATEtoDATE(byte[] timestamp) Convert a byte array representing a TIMESTAMP object to a Oracle DATE ObjecttoJdbc()Returns the JDBC representation of the datum objectConverts TIMESTAMP to LocalDate.static LocalDatetoLocalDate(byte[] timestamp) Convert a byte array representing a TIMESTAMP object to a Java LocalDateConverts TIMESTAMP to LocalDateTime.static LocalDateTimetoLocalDateTime(byte[] timestamp) Convert a byte array representing a TIMESTAMP object to a Java LocalDateTimeConverts TIMESTAMP to LocalTime.static LocalTimetoLocalTime(byte[] timestamp) Convert a byte array representing a TIMESTAMP object to a Java LocalTimetoString()static StringtoString(byte[] bytes) Converts a TIMESTAMP to a stringstatic TimetoTime(byte[] timestamp) Convert a byte array representing a TIMESTAMP object to a Java Time Objectstatic TimestamptoTimestamp(byte[] timestamp) Convert a byte array representing a TIMESTAMP object to a Java Timestamp Objectstatic TimestamptoTimestamp(byte[] timestamp, Calendar cal) Convert a byte array representing a TIMESTAMP object to a Java Timestamp Object given Calendar objectMethods inherited from class oracle.sql.Datum
asciiStreamValue, bigDecimalValue, binaryStreamValue, booleanValue, bytesEqual, bytesHashCode, byteValue, characterStreamValue, compareBytes, doubleValue, equals, floatValue, getBytes, getConnectionDuringExceptionHandling, getLength, getStream, intValue, isNull, longValue, setBytes, setShareBytes, shareBytes, stringValue, timeValue, toClass
-
Field Details
-
SIZE_DATE
public static final int SIZE_DATE- See Also:
-
SIZE_TIMESTAMP
public static final int SIZE_TIMESTAMP- See Also:
-
SIZE_TIMESTAMP_NOFRAC
public static final int SIZE_TIMESTAMP_NOFRAC- See Also:
-
-
Constructor Details
-
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
Create an Oracle TIMESTAMP object represented by the given Java Time- Parameters:
time- Java Time object
-
TIMESTAMP
Create an Oracle TIMESTAMP object represented by the Java Date- Parameters:
date- Java Date object
-
TIMESTAMP
Create an Oracle TIMESTAMP object represented by the Java Timestamp- Parameters:
timestamp- Java Timestamp object
-
TIMESTAMP
Create an Oracle TIMESTAMP object represented by the Java Timestamp and Calendar- Parameters:
timestamp- Java Timestamp objectcal- Java Util Calendar object
-
TIMESTAMP
Create an Oracle TIMESTAMP object represented by the Oracle DATE- Parameters:
date- Oracle DATE object
-
TIMESTAMP
Create a TIMESTAMP object given a Java String object.- Parameters:
str- Java String object
-
TIMESTAMP
Create a TIMESTAMP object given a Java OffsetDateTime- Parameters:
odt- OffsetDateTime object
-
TIMESTAMP
Create a TIMESTAMP object given a Java ZonedDateTime- Parameters:
zdt- ZonedDateTime object
-
TIMESTAMP
Create a TIMESTAMP object given a Java LocalDateTime- Parameters:
zdt- LocalDateTime object
-
TIMESTAMP
Create a TIMESTAMP object given a Java LocalTime- Parameters:
lt- LocalTime object
-
TIMESTAMP
Create a TIMESTAMP object given a Java LocalDate- Parameters:
ld- LocalDate object
-
TIMESTAMP
Create a TIMESTAMP object given a Java OffsetTime- Parameters:
ot- OffsetTime object
-
-
Method Details
-
toDate
Convert a byte array representing a TIMESTAMP object to a Java Date Object- Parameters:
timestamp- Oracle TIMESTAMP object- Returns:
- the Java date object represented by Oracle TIMESTAMP object
- Throws:
SQLException
-
toTime
Convert a byte array representing a TIMESTAMP object to a Java Time Object- Parameters:
timestamp- Oracle TIMESTAMP object- Returns:
- the java.sql.Time object represented by Oracle TIMESTAMP object. Only the hour, minute and seconds are contained in the java.sql.Time object that is returned and hence callers should not attempt to access the date component of the returned object.
- Throws:
SQLException
-
toTimestamp
Convert a byte array representing a TIMESTAMP object to a Java Timestamp Object- Parameters:
timestamp- Oracle TIMESTAMP object- Returns:
- the Java timestamp object represented by Oracle TIMESTAMP object
- Throws:
SQLException
-
toTimestamp
Convert a byte array representing a TIMESTAMP object to a Java Timestamp Object given Calendar object- Parameters:
timestamp- Oracle TIMESTAMP object to be convertedcal- java.utl.Calendar object- Returns:
- the java.sql.Timestamp object represented by the Oracle TIMESTAMP object.
- Throws:
SQLException
-
toDATE
Convert a byte array representing a TIMESTAMP object to a Oracle DATE Object- Parameters:
timestamp- Oracle TIMESTAMP object- Returns:
- the oracle DATE object represented by Oracle TIMESTAMP object
- Throws:
SQLException
-
timestampValue
Calls toTimestamp to convert internal Oracle TIMESTAMP to a Java Timestamp.- Overrides:
timestampValuein classDatum- Returns:
- a Java Timestamp value
- Throws:
SQLException
-
timestampValue
Calls toTimestamp to convert internal Oracle TIMESTAMP and Calendar to a Java Timestamp.- Overrides:
timestampValuein classDatum- Returns:
- a Java Timestamp value
- Throws:
SQLException
-
toString
Converts a TIMESTAMP to a string- Parameters:
date- a byte array- Returns:
- String representing the date
-
toBytes
public byte[] toBytes()Convert Oracle TIMESTAMP object into a byte array- Specified by:
toBytesin interfaceoracle.jdbc.internal.OracleTimestamp- Returns:
- the byte array stored in the TIMESTAMP object
-
toBytes
Convert Java Time to Oracle TIMESTAMP.- Parameters:
time- java.sql.Time object to be converted.- Returns:
- the byte array representing the java Time.
-
toBytes
Convert Java Date to Oracle TIMESTAMP.- Parameters:
date- java.sql.Date object to be converted.- Returns:
- the byte array representing the java Date.
-
toBytes
Convert Java Timestamp to Oracle TIMESTAMP- Parameters:
Timestamp- java.sql.Timestamp object to be converted.- Returns:
- the byte array representing the java timestamp.
-
toBytes
Convert Java Timestamp and Java Calendar to Oracle TIMESTAMP- Parameters:
Timestamp- java.sql.Timestamp object to be converted.Calendar- java.util.Calendar object to be converted.- Returns:
- the byte array representing the java timestamp.
-
toBytes
Convert Oracle DATE to Oracle TIMESTAMP- Parameters:
date- oracle.sql.Timestamp object to be converted.- Returns:
- the byte array representing the oracle DATE.
-
toBytes
Convert Java String to Oracle TIMESTAMP.- Parameters:
str- java.lang.String object to be converted.- Returns:
- the byte array representing the input string.
-
toJdbc
Returns the JDBC representation of the datum object- Specified by:
toJdbcin classDatum- Returns:
- an object containing the JDBC value
- Throws:
SQLException- if conversion to JDBC representation results in an error
-
makeJdbcArray
Returns a JDBC array representation of the datum- Specified by:
makeJdbcArrayin classDatum- Parameters:
arraySize- size of the array- Returns:
- an object containing the JDBC array value
-
isConvertibleTo
Determines if the object can be converted to a particular class- Specified by:
isConvertibleToin classDatum- 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(Connection conn, TIMESTAMP tstamp, TimeZone tz1, TimeZone tz2) throws 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:
SQLException
-
stringValue
Calls toString to convert internal Oracle TIMESTAMP to a Java String.- Overrides:
stringValuein classDatum- Returns:
- a Java String value
-
toString
-
getOracleYear
-
getOracleYear
public static int getOracleYear(int jYear) -
dateValue
Calls toDate to convert internal Oracle TIMESTAMP to a Java Date.- Overrides:
dateValuein classDatum- Returns:
- a Java Date Object
- Throws:
SQLException
-
timeValue
Calls toTime to convert internal Oracle Date to a Java Time.- Overrides:
timeValuein classDatum- Returns:
- a Java Time value
- Throws:
SQLException
-
getJavaYear
public static int getJavaYear(int cent, int decade) -
of
Creates TIMESTAMP from the LocalDateTime.- Parameters:
ldt- LocalDateTime object- Returns:
- TIMESTAMP object
- Throws:
SQLException
-
toLocalDateTime
Converts TIMESTAMP to LocalDateTime.- Returns:
- LocalDateTime object.
- Throws:
SQLException
-
localDateTimeValue
Converts TIMESTAMP to LocalDateTime.- Returns:
- LocalDateTime object.
- Throws:
SQLException
-
of
Create a TIMESTAMP object given a Java OffsetDateTime- Parameters:
odt- OffsetDateTime object
-
toLocalDateTime
Convert a byte array representing a TIMESTAMP object to a Java LocalDateTime- Parameters:
timestamp- Oracle TIMESTAMP object to be converted- Returns:
- the java.time.LocalDateTime object represented by the Oracle TIMESTAMP object.
- Throws:
SQLException
-
toLocalTime
Convert a byte array representing a TIMESTAMP object to a Java LocalTime- Parameters:
timestamp- Oracle TIMESTAMP object to be converted- Returns:
- the java.time.LocalTime object represented by the Oracle TIMESTAMP object.
- Throws:
SQLException
-
toLocalDate
Convert a byte array representing a TIMESTAMP object to a Java LocalDate- Parameters:
timestamp- Oracle TIMESTAMP object to be converted- Returns:
- the java.time.LocalDate object represented by the Oracle TIMESTAMP object.
- Throws:
SQLException
-
of
Create a TIMESTAMP object given a Java ZonedDateTime- Parameters:
zdt- ZonedDateTime object
-
of
Create a TIMESTAMP object given a Java OffsetTime- Parameters:
ot- OffsetTime object
-
of
Creates TIMESTAMP from the LocalTime.- Parameters:
lt- LocalTime object- Returns:
- TIMESTAMP object
- Throws:
SQLException
-
toLocalTime
Converts TIMESTAMP to LocalTime.- Returns:
- LocalTime object.
- Throws:
SQLException
-
localTimeValue
Converts TIMESTAMP to LocalTime.- Returns:
- LocalTime object.
- Throws:
SQLException
-
of
Creates TIMESTAMP from the LocalDate.- Parameters:
ld- LocalDate object- Returns:
- TIMESTAMP object
- Throws:
SQLException
-
toLocalDate
Converts TIMESTAMP to LocalDate.- Returns:
- LocalDate object.
- Throws:
SQLException
-
localDateValue
Converts TIMESTAMP to LocalDate.- Returns:
- LocalTime object.
- Throws:
SQLException
-
toBytes
Convert Java OffsetDateTime to Oracle TIMESTAMP- Parameters:
odt- OffsetDateTime object- Returns:
- the byte array representing the java OffsetDateTime.
-
toBytes
Convert Java ZonedDateTime to Oracle TIMESTAMP- Parameters:
zdt- ZonedDateTime object- Returns:
- the byte array representing the java ZonedDateTime.
-
toBytes
Convert Java OffsetTime to Oracle TIMESTAMP- Parameters:
ot- OffsetTime object- Returns:
- the byte array representing the java OffsetTime.
-
toBytes
Convert Java LocalDate to Oracle TIMESTAMP- Parameters:
ld- LocalDate object- Returns:
- the byte array representing the java LocalDate.
-
toBytes
Convert Java LocalDateTime to Oracle TIMESTAMP- Parameters:
ldt- LocalDateTime object- Returns:
- the byte array representing the java LocalDateTime.
-
toBytes
Convert Java LocalTime to Oracle TIMESTAMP- Parameters:
lt- LocalTime object- Returns:
- the byte array representing the java LocalTime.
-