Enum TimeZoneStorageType

  • All Implemented Interfaces:
    Serializable, Comparable<TimeZoneStorageType>

    @Incubating
    public enum TimeZoneStorageType
    extends Enum<TimeZoneStorageType>
    Describes the storage of timezone information for zoned datetime types, in particular, for the types OffsetDateTime and ZonedDateTime.

    A default TimeZoneStorageType may be configured explicitly using "hibernate.timezone.default_storage". Otherwise, the storage type may be overridden for a given field or property of an entity using the TimeZoneStorage annotation.

    In choosing a TimeZoneStorageType we must consider whether a round trip to the database, writing and then reading a zoned datetime, preserves:

    • the instant represented by the zoned datetime, and/or
    • the offset or zone in which the instant is represented.

    We must also consider the physical representation of the zoned datetime in the database table.

    The default strategy guarantees that a round trip preserves the instant. Whether the zone or offset is preserved depends on whether the underlying database has a timestamp with time zone type which preserves offsets:

    • if the database does indeed have such an ANSI-compliant type, then both instant and zone or offset are preserved by round trips, but
    • if not, it's guaranteed that the physical representation is in UTC, so that datetimes retrieved from the database will be represented in UTC.

    When this default strategy is not appropriate, recommended alternatives are:

    • AUTO or COLUMN, which each guarantee that both instant and zone or offset are preserved by round trips on every platform, or
    • NORMALIZE_UTC, which guarantees that only the instant is preserved, and that datetimes retrieved from the database will always be represented in UTC.
    Since:
    6.0
    See Also:
    TimeZoneStorage, TimeZoneStorageStrategy
    • Method Detail

      • values

        public static TimeZoneStorageType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (TimeZoneStorageType c : TimeZoneStorageType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static TimeZoneStorageType valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null