Enum Class DateFormat
- All Implemented Interfaces:
Serializable,Comparable<DateFormat>,Constable
Date values.
Used by MarshallingContext.Builder.dateFormat(DateFormat),
Marshalled.dateFormat(),
MarshalledProp.dateFormat(), and
MarshalledConfig.dateFormat() to control how Date
values are written to and read from the wire.
The default is ISO_LOCAL_DATE_TIME which preserves the historical wire output produced
before this enum existed (note: Date carries no zone so the default emits a local date-time,
deliberately differing from CalendarFormat.ISO_OFFSET_DATE_TIME).
Numeric formats (MILLIS) emit native numeric wire types on binary serializers
(BSON / CBOR / MsgPack) and bare numbers on text formats. Text formats emit a quoted ISO 8601 string for
every other constant.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionDateTimeFormatter.BASIC_ISO_DATE:"20111203" .DateTimeFormatter.ISO_DATE_TIME:"2011-12-03T10:15:30+01:00[Europe/Paris]" .DateTimeFormatter.ISO_INSTANT:"2011-12-03T10:15:30Z" .DateTimeFormatter.ISO_LOCAL_DATE:"2011-12-03" .DateTimeFormatter.ISO_LOCAL_DATE_TIME(the default):"2011-12-03T10:15:30" .DateTimeFormatter.ISO_LOCAL_TIME:"10:15:30" .DateTimeFormatter.ISO_OFFSET_DATE:"2011-12-03+01:00" .DateTimeFormatter.ISO_OFFSET_DATE_TIME:"2011-12-03T10:15:30+01:00" .DateTimeFormatter.ISO_OFFSET_TIME:"10:15:30+01:00" .DateTimeFormatter.ISO_ORDINAL_DATE:"2012-337" .DateTimeFormatter.ISO_WEEK_DATE:"2012-W48-6" .DateTimeFormatter.ISO_ZONED_DATE_TIME:"2011-12-03T10:15:30+01:00[Europe/Paris]" .Epoch milliseconds as a numeric value.Sentinel meaning "no value configured" — falls through to the next-higher precedence level.DateTimeFormatter.RFC_1123_DATE_TIME:"Tue, 3 Jun 2008 11:05:30 GMT" . -
Method Summary
Modifier and TypeMethodDescriptionFormats the specified value using this format.booleanReturnstrue if this format is numeric on the wire.Parses the specified wire value using this format.static DateFormatReturns the enum constant of this class with the specified name.static DateFormat[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NOT_SET
Sentinel meaning "no value configured" — falls through to the next-higher precedence level. -
BASIC_ISO_DATE
DateTimeFormatter.BASIC_ISO_DATE:"20111203" . -
ISO_DATE
-
ISO_DATE_TIME
DateTimeFormatter.ISO_DATE_TIME:"2011-12-03T10:15:30+01:00[Europe/Paris]" . -
ISO_INSTANT
DateTimeFormatter.ISO_INSTANT:"2011-12-03T10:15:30Z" . -
ISO_LOCAL_DATE
DateTimeFormatter.ISO_LOCAL_DATE:"2011-12-03" . -
ISO_LOCAL_DATE_TIME
DateTimeFormatter.ISO_LOCAL_DATE_TIME(the default):"2011-12-03T10:15:30" . -
ISO_LOCAL_TIME
DateTimeFormatter.ISO_LOCAL_TIME:"10:15:30" . -
ISO_OFFSET_DATE
DateTimeFormatter.ISO_OFFSET_DATE:"2011-12-03+01:00" . -
ISO_OFFSET_DATE_TIME
DateTimeFormatter.ISO_OFFSET_DATE_TIME:"2011-12-03T10:15:30+01:00" . -
ISO_OFFSET_TIME
DateTimeFormatter.ISO_OFFSET_TIME:"10:15:30+01:00" . -
ISO_ORDINAL_DATE
DateTimeFormatter.ISO_ORDINAL_DATE:"2012-337" . -
ISO_TIME
-
ISO_WEEK_DATE
DateTimeFormatter.ISO_WEEK_DATE:"2012-W48-6" . -
ISO_ZONED_DATE_TIME
DateTimeFormatter.ISO_ZONED_DATE_TIME:"2011-12-03T10:15:30+01:00[Europe/Paris]" . -
RFC_1123_DATE_TIME
DateTimeFormatter.RFC_1123_DATE_TIME:"Tue, 3 Jun 2008 11:05:30 GMT" . -
MILLIS
Epoch milliseconds as a numeric value.Emitted as a native int64 by binary serializers (BSON / CBOR / MsgPack) and as a bare integer literal by text serializers.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null
-
format
Formats the specified value using this format.- Parameters:
value- The value to format. Can benull (returnsnull ).zoneId- The default zone id used to interpret the date.- Returns:
- The formatted string, or
null ifvalueisnull .
-
parse
Parses the specified wire value using this format.- Parameters:
value- The wire value. Can benull or blank (returnsnull ).zoneId- The default zone id used for time-only / unzoned values.- Returns:
- The parsed
Date, ornull ifvalueisnull or blank.
-
isNumeric
Returnstrue if this format is numeric on the wire.- Returns:
true if this format emits a numeric wire value.
-