For an ISO8601 compliant datetime
2004-10-19 10:23:54+02
Is it possible to have that value, with +02
offset, reflected in the
Java developers can use Joda Time combined with Jadira UserType's PersistentDateTimeAndZone. Example:
@Basic(optional = false)
@Columns(columns = { @Column(name = "modificationtime"),
@Column(name = "modificationtime_zone") })
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTimeAndZone")
@Index(name = "payment_modificationtime_idx")
private DateTime modificationTime = null;
In this example, the DateTime
information is in 2 columns:
modificationtime timestamp without time zone
to store the timestamp in UTC time zonemodificationtime_zone varchar(255)
to store the time zone ID as string (e.g. America/Caracas
)While Joda Time and Jadira (and Hibernate) is specific to Java (and is the de facto approach), the above approach of structuring the RDBMS columns to store both timestamp and time zone can be applied to any programming language.