phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheyenne Forbes <cheyenne.osanu.for...@gmail.com>
Subject Differences between the date/time types
Date Wed, 15 Feb 2017 20:55:27 GMT
I cant find the difference between the date/time types, arent all of them
the same? also should I parse them as int or string?
TIME Type
TIME

The time data type. The format is yyyy-MM-dd hh:mm:ss, with both the date
and time parts maintained. Mapped to java.sql.Time. The binary
representation is an 8 byte long (the number of milliseconds from the
epoch), making it possible (although not necessarily recommended) to store
more information within a TIME column than what is provided by java.sql.Time.
Note that the internal representation is based on a number of milliseconds
since the epoch (which is based on a time in GMT), while java.sql.Time will
format times based on the client's local time zone. Please note that this
TIME type is different than the TIME type as defined by the SQL 92 standard
in that it includes year, month, and day components. As such, it is not in
compliance with the JDBC APIs. As the underlying data is still stored as a
long, only the presentation of the value is incorrect.

Example:

TIME
DATE Type
DATE

The date data type. The format is yyyy-MM-dd hh:mm:ss, with both the date
and time parts maintained to a millisecond accuracy. Mapped to java.sql.Date.
The binary representation is an 8 byte long (the number of milliseconds
from the epoch), making it possible (although not necessarily recommended)
to store more information within a DATE column than what is provided by
java.sql.Date. Note that the internal representation is based on a number
of milliseconds since the epoch (which is based on a time in GMT), while
java.sql.Date will format dates based on the client's local time zone.
Please note that this DATE type is different than the DATE type as defined
by the SQL 92 standard in that it includes a time component. As such, it is
not in compliance with the JDBC APIs. As the underlying data is still
stored as a long, only the presentation of the value is incorrect.

Example:

DATE
TIMESTAMP Type
TIMESTAMP

The timestamp data type. The format is yyyy-MM-dd hh:mm:ss[.nnnnnnnnn].
Mapped to java.sql.Timestamp with an internal representation of the number
of nanos from the epoch. The binary representation is 12 bytes: an 8 byte
long for the epoch time plus a 4 byte integer for the nanos. Note that the
internal representation is based on a number of milliseconds since the
epoch (which is based on a time in GMT), while java.sql.Timestamp will
format timestamps based on the client's local time zone.

Example:

TIMESTAMP
UNSIGNED_TIME Type
UNSIGNED_TIME

The unsigned time data type. The format is yyyy-MM-dd hh:mm:ss, with both
the date and time parts maintained to the millisecond accuracy. Mapped to
java.sql.Time. The binary representation is an 8 byte long (the number of
milliseconds from the epoch) matching the HBase.toBytes(long) method. The
purpose of this type is to map to existing HBase data that was serialized
using this HBase utility method. If that is not the case, use the regular
signed type instead.

Example:

UNSIGNED_TIME
UNSIGNED_DATE Type
UNSIGNED_DATE

The unsigned date data type. The format is yyyy-MM-dd hh:mm:ss, with both
the date and time parts maintained to a millisecond accuracy. Mapped to
java.sql.Date. The binary representation is an 8 byte long (the number of
milliseconds from the epoch) matching the HBase.toBytes(long) method. The
purpose of this type is to map to existing HBase data that was serialized
using this HBase utility method. If that is not the case, use the regular
signed type instead.

Example:

UNSIGNED_DATE
UNSIGNED_TIMESTAMP Type
UNSIGNED_TIMESTAMP

The timestamp data type. The format is yyyy-MM-dd hh:mm:ss[.nnnnnnnnn].
Mapped to java.sql.Timestamp with an internal representation of the number
of nanos from the epoch. The binary representation is 12 bytes: an 8 byte
long for the epoch time plus a 4 byte integer for the nanos with the long
serialized through the HBase.toBytes(long) method. The purpose of this type
is to map to existing HBase data that was serialized using this HBase
utility method. If that is not the case, use the regular signed type
instead.

Example:

UNSIGNED_TIMESTAMP

Mime
View raw message