From 6709f72b130e0342c6b92f82e1b7a7da8bbcdcec Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 17 May 2015 19:46:00 -0700 Subject: [PATCH] Work on #794: add the feature. --- release-notes/VERSION | 2 + .../databind/SerializationFeature.java | 41 +++++++++++++------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/release-notes/VERSION b/release-notes/VERSION index e53fc8bfac..72ed7b3192 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -47,6 +47,8 @@ Project: jackson-databind (suggested by rgoldberg@githin) #790: Add `JsonNode.equals(Comparator, JsonNode)` to support configurable/external equality comparison +#794: Add `SerializationFeature.WRITE_DATES_WITH_ZONE_ID` to allow inclusion/exclusion of + timezone id for date/time values (as opposed to timezone offset) - Remove old cglib compatibility tests; cause problems in Eclipse 2.5.4 (not yet released) diff --git a/src/main/java/com/fasterxml/jackson/databind/SerializationFeature.java b/src/main/java/com/fasterxml/jackson/databind/SerializationFeature.java index 875433f31e..0cad93cdae 100644 --- a/src/main/java/com/fasterxml/jackson/databind/SerializationFeature.java +++ b/src/main/java/com/fasterxml/jackson/databind/SerializationFeature.java @@ -161,7 +161,7 @@ public enum SerializationFeature implements ConfigFeature */ /** - * Feature that determines whether {@link java.util.Date} values + * Feature that determines whether Date (and date/time) values * (and Date-based things like {@link java.util.Calendar}s) are to be * serialized as numeric timestamps (true; the default), * or as something else (usually textual representation). @@ -185,7 +185,20 @@ public enum SerializationFeature implements ConfigFeature WRITE_DATES_AS_TIMESTAMPS(true), /** - * Feature that determines whether time values that represents time periods + * Feature that determines whether {@link java.util.Date}s + * (and sub-types) used as {@link java.util.Map} keys are serialized + * as timestamps or not (if not, will be serialized as textual + * values). + *

+ * Default value is 'false', meaning that Date-valued Map keys are serialized + * as textual (ISO-8601) values. + *

+ * Feature is disabled by default. + */ + WRITE_DATE_KEYS_AS_TIMESTAMPS(false), + + /** + * Feature that determines whether date/time values that represents time periods * (durations, periods, ranges) are to be serialized by default using * a numeric (true) or textual (false) representations. Note that numeric * representation may mean either simple number, or an array of numbers, @@ -199,21 +212,25 @@ public enum SerializationFeature implements ConfigFeature * * @since 2.5 */ - WRITE_DURATIONS_AS_TIMESTAMPS(true), + WRITE_DATES_WITH_ZONE_ID(false), /** - * Feature that determines whether {@link java.util.Date}s - * (and sub-types) used as {@link java.util.Map} keys are serialized - * as timestamps or not (if not, will be serialized as textual - * values). + * Feature that determines whether time values that represents time periods + * (durations, periods, ranges) are to be serialized by default using + * a numeric (true) or textual (false) representations. Note that numeric + * representation may mean either simple number, or an array of numbers, + * depending on type. *

- * Default value is 'false', meaning that Date-valued Map keys are serialized - * as textual (ISO-8601) values. + * Note: whether {@link java.util.Map} keys are serialized as Strings + * or not is controlled using {@link #WRITE_DATE_KEYS_AS_TIMESTAMPS}. *

- * Feature is disabled by default. + * Feature is enabled by default, so that period/duration are by default + * serialized as timestamps. + * + * @since 2.5 */ - WRITE_DATE_KEYS_AS_TIMESTAMPS(false), - + WRITE_DURATIONS_AS_TIMESTAMPS(true), + /** * Feature that determines how type char[] is serialized: * when enabled, will be serialized as an explict JSON array (with