com.informix.jdbc

## Class IfxDateTime

- java.lang.Object
- - com.informix.jdbc.IfxObject
  - - com.informix.jdbc.IfxDateTime

    public class IfxDateTime
    extends IfxObject

Support for datetime datatypes. This class derived from IfxObject class.

See Also:
  `IfxObject`

### Field Summary

Fields
`protected java.util.Calendar` `dbCalendar`
`static byte` `TU_DAY`
`static byte` `TU_F1`
`static byte` `TU_F2`
`static byte` `TU_F3`
`static byte` `TU_F4`
`static byte` `TU_F5`
`static byte` `TU_FRAC`
`static byte` `TU_HOUR`
`static byte` `TU_MINUTE`
`static byte` `TU_MONTH`
`static byte` `TU_SECOND`
`static byte` `TU_YEAR`

### Fields inherited from class com.informix.jdbc.IfxObject

`conn, encodedLength, extendedID, extendedName, extendedOwner, ifxType, isNull, jdbcType, sourceType, trace, typeMap, used_in_update`

### Method Summary

Methods
`boolean` `equals(java.lang.Object other)` Determine if two objects are equal.
`void` `fromCalendar(java.util.Calendar calendar)`
`void` `fromCalendar(java.util.GregorianCalendar calendar)` Have the implementation specific class due to limitations in using reflection from the code in IfxObject, so we cannot use the Calendar interface
`void` `fromDate(java.sql.Date date)` Convert from a JDBC date to IfxDateTime
`void` `fromDate(java.util.Date date)` Convert from a java.util.Date (which is a very common date object to use ) into IfxDateTime
`void` `fromIfx(byte[] b, int offset, int length, short prec)` Set value to the given Informix network format
`void` `fromIfx(byte[] b, short prec)` Set value to the given Informix network format
`void` `fromRawDateTime(byte[] b, short prec)`
`void` `fromString(java.lang.String str)` Convert from a String to a IfxDatetime
`void` `fromTime(java.sql.Time time)`
`void` `fromTimestamp(java.sql.Timestamp ts)`
`void` `fromTimestamp(java.sql.Timestamp ts, short qual)`
`short` `getEncodedLength()` Default method for getting encoded length.
`static byte` `getEndCode(short qualifier)` Extract an ending field code from a qualifier
`int` `getNanos()` Return the nanos set for this datetime object if set.
`int` `getRawEncodedLength()`
`static byte` `getStartCode(short qual)` Given a qualifier extract the start code
`boolean` `isTimeValue()`
`void` `setDateTimeByStCode(byte startCode)`
`void` `setDateTimeByStEndCode(byte startCode, byte endCode)`
`void` `setDateTimeType(int nanos, byte startCode, byte endCode)`
`void` `setNanos(int nanos)` Set the nanos for this datetime object.
`java.util.Calendar` `toCalendar()`
`java.sql.Date` `toDate()` Convert IfxDateTime to a JDBC date
`byte[]` `toIfx()` Convert value to Informix network type
`byte[]` `toIfxTuple()` Convert value to Informix network tuple format
`java.lang.Object` `toObject()` Returns the equivalent Java object
`java.lang.String` `toString()` Convert a IfxDateTime value to a string based on GLS DATETIME non-ANSI format if USE_DTENV property is set, otherwise use ANSI format.
`java.sql.Time` `toTime()` Return the Time value
`java.sql.Timestamp` `toTimestamp()` Return the timestamp value
`java.lang.String` `toUnloadString()` Convert to string format which is compatible with format generated by SQL unload command.
`boolean` `truncateDataForPut(byte colDefEndCode)` Truncates the data from given timestamp to match the column definition as returned by server describe information To be used only in case on INSERT operation, note that for normal inserts server will anyway do this, however if IFX_USEPUT is set then it is driver responsibility to truncate the data for datetime column.

### Methods inherited from class com.informix.jdbc.IfxObject

`clear, clearWarning, fromAsciiStream, fromAsciiStream, fromBinaryStream, fromBinaryStream, fromBlob, fromBoolean, fromBoolean, fromByte, fromByte, fromBytes, fromCharacterStream, fromCharacterStream, fromClob, fromDecimal, fromDecimal, fromDouble, fromDouble, fromFloat, fromFloat, fromIfx, fromIfx, fromIfx, fromIfx, fromInputStream, fromInputStream, fromInt, fromInt, fromIntervalDF, fromIntervalYM, fromLong, fromLong, fromNClob, fromObject, fromObject, fromObject, fromRowId, fromShort, fromShort, fromSQLXML, fromString, get_used_in_update, getWarning, isNull, nullify, set_used_in_update, setConnection, setExtendedTypeName, setIfxType, setTypeMap, toAsciiStream, toBinaryStream, toBlob, toBoolean, toByte, toBytes, toCharacterStream, toClob, toDecimal, toDouble, toFloat, toIfxBSONObject, toInputStream, toInt, toInterval, toIntervalDF, toIntervalYM, toLong, toNClob, toObject, toRowId, toShort, toSQLXML, unnullify`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### dbCalendar

    protected java.util.Calendar dbCalendar

#### TU_YEAR

    public static final byte TU_YEAR

See Also:
  Constant Field Values

#### TU_MONTH

    public static final byte TU_MONTH

See Also:
  Constant Field Values

#### TU_DAY

    public static final byte TU_DAY

See Also:
  Constant Field Values

#### TU_HOUR

    public static final byte TU_HOUR

See Also:
  Constant Field Values

#### TU_MINUTE

    public static final byte TU_MINUTE

See Also:
  Constant Field Values

#### TU_SECOND

    public static final byte TU_SECOND

See Also:
  Constant Field Values

#### TU_FRAC

    public static final byte TU_FRAC

See Also:
  Constant Field Values

#### TU_F1

    public static final byte TU_F1

See Also:
  Constant Field Values

#### TU_F2

    public static final byte TU_F2

See Also:
  Constant Field Values

#### TU_F3

    public static final byte TU_F3

See Also:
  Constant Field Values

#### TU_F4

    public static final byte TU_F4

See Also:
  Constant Field Values

#### TU_F5

    public static final byte TU_F5

See Also:
  Constant Field Values

### Method Detail

#### toIfx

    public byte[] toIfx()

Convert value to Informix network type

Overrides:
  `toIfx` in class `IfxObject`
Returns:
  a byte array

#### toIfxTuple

    public byte[] toIfxTuple()

Convert value to Informix network tuple format

Overrides:
  `toIfxTuple` in class `IfxObject`
Returns:
  a byte array

#### fromIfx

    public void fromIfx(byte[] b,
               short prec)

Set value to the given Informix network format

Overrides:
  `fromIfx` in class `IfxObject`
Parameters:
  `b` - a byte array in network format.

#### fromIfx

    public void fromIfx(byte[] b,
               int offset,
               int length,
               short prec)

Set value to the given Informix network format

Overrides:
  `fromIfx` in class `IfxObject`
Parameters:
  `b` - a byte array in network format.

#### toObject

    public java.lang.Object toObject()

Returns the equivalent Java object

Overrides:
  `toObject` in class `IfxObject`

#### toDate

    public java.sql.Date toDate()

Convert IfxDateTime to a JDBC date

Overrides:
  `toDate` in class `IfxObject`

#### fromDate

    public void fromDate(java.sql.Date date)

Convert from a JDBC date to IfxDateTime

Overrides:
  `fromDate` in class `IfxObject`

#### fromCalendar

    public void fromCalendar(java.util.GregorianCalendar calendar)

Have the implementation specific class due to limitations in using reflection from the code in IfxObject, so we cannot use the Calendar interface

Parameters:
  `calendar` -

#### toCalendar

    public java.util.Calendar toCalendar()

#### fromCalendar

    public void fromCalendar(java.util.Calendar calendar)

#### fromDate

    public void fromDate(java.util.Date date)

Convert from a java.util.Date (which is a very common date object to use ) into IfxDateTime

#### toTimestamp

    public java.sql.Timestamp toTimestamp()

Return the timestamp value

Overrides:
  `toTimestamp` in class `IfxObject`

#### fromTimestamp

    public void fromTimestamp(java.sql.Timestamp ts)

Overrides:
  `fromTimestamp` in class `IfxObject`

#### fromRawDateTime

    public void fromRawDateTime(byte[] b,
                       short prec)

#### fromTimestamp

    public void fromTimestamp(java.sql.Timestamp ts,
                     short qual)

#### toTime

    public java.sql.Time toTime()

Return the Time value

Overrides:
  `toTime` in class `IfxObject`

#### fromTime

    public void fromTime(java.sql.Time time)
                  throws java.sql.SQLException

Overrides:
  `fromTime` in class `IfxObject`
Throws:
  `java.sql.SQLException`

#### toString

    public java.lang.String toString()

Convert a IfxDateTime value to a string based on GLS DATETIME non-ANSI format if USE_DTENV property is set, otherwise use ANSI format. Method call to convertDateTimeStr() will determine the format of the datetime string.

Overrides:
  `toString` in class `IfxObject`
Returns:
  a string value representation of the datetime value.

#### toUnloadString

    public java.lang.String toUnloadString()

Description copied from class: `IfxObject`
Convert to string format which is compatible with format generated by SQL unload command.

Overrides:
  `toUnloadString` in class `IfxObject`
Returns:
  the converted String object, or null on error

#### fromString

    public void fromString(java.lang.String str)
                    throws java.sql.SQLException

Convert from a String to a IfxDatetime

Overrides:
  `fromString` in class `IfxObject`
Parameters:
  `str` - the String value
Throws:
  `java.sql.SQLException` - if the conversion fails

#### equals

    public boolean equals(java.lang.Object other)

Determine if two objects are equal.

Overrides:
  `equals` in class `IfxObject`
Parameters:
  `other` - the other object to compare with this object
Returns:
  true if the objects are equal

#### getStartCode

    public static byte getStartCode(short qual)

Given a qualifier extract the start code

Parameters:
  `qual` - The qualifier
Returns:
  The start code for the interval or datetime field

#### getEndCode

    public static byte getEndCode(short qualifier)

Extract an ending field code from a qualifier

Parameters:
  `qualifier` - The qualifier
Returns:
  The end code which has been extracted

#### getEncodedLength

    public short getEncodedLength()

Description copied from class: `IfxObject`
Default method for getting encoded length.

Overrides:
  `getEncodedLength` in class `IfxObject`

#### getRawEncodedLength

    public int getRawEncodedLength()

#### isTimeValue

    public boolean isTimeValue()

#### setDateTimeType

    public void setDateTimeType(int nanos,
                       byte startCode,
                       byte endCode)

#### setDateTimeByStCode

    public void setDateTimeByStCode(byte startCode)

#### setDateTimeByStEndCode

    public void setDateTimeByStEndCode(byte startCode,
                              byte endCode)

#### getNanos

    public int getNanos()

Return the nanos set for this datetime object if set.

Returns:

#### setNanos

    public void setNanos(int nanos)

Set the nanos for this datetime object.

Parameters:
  `nanos` -

#### truncateDataForPut

    public boolean truncateDataForPut(byte colDefEndCode)

Truncates the data from given timestamp to match the column definition as returned by server describe information To be used only in case on INSERT operation, note that for normal inserts server will anyway do this, however if IFX_USEPUT is set then it is driver responsibility to truncate the data for datetime column. This method ends up using deprecated methods from java.sql.Date.setXXX(), which is not a concern since all we do is set the field in the timestamp to 0

Parameters:
  `colDefEndCode` -
Returns:
  true if data was truncated
Since:
  4.10.JC5