|
1 | 1 | package tools.jackson.databind.cfg;
|
2 | 2 |
|
3 |
| -import tools.jackson.databind.DeserializationFeature; |
| 3 | +import tools.jackson.databind.DeserializationContext; |
4 | 4 |
|
5 | 5 | /**
|
6 | 6 | * Configurable on/off features to configure Date/Time handling.
|
|
12 | 12 | */
|
13 | 13 | public enum DateTimeFeature implements DatatypeFeature
|
14 | 14 | {
|
| 15 | + /** |
| 16 | + * Feature that specifies whether context provided {@link java.util.TimeZone} |
| 17 | + * ({@link DeserializationContext#getTimeZone()} should be used to adjust Date/Time |
| 18 | + * values on deserialization, even if value itself contains timezone information. |
| 19 | + * If enabled, contextual <code>TimeZone</code> will essentially override any other |
| 20 | + * TimeZone information; if disabled, it will only be used if value itself does not |
| 21 | + * contain any TimeZone information. |
| 22 | + *<p> |
| 23 | + * Note that exact behavior depends on date/time types in question; and specifically |
| 24 | + * JDK type of {@link java.util.Date} does NOT have in-built timezone information |
| 25 | + * so this setting has no effect. |
| 26 | + * Further, while {@link java.util.Calendar} does have this information basic |
| 27 | + * JDK {@link java.text.SimpleDateFormat} is unable to retain parsed zone information, |
| 28 | + * and as a result, {@link java.util.Calendar} will always get context timezone |
| 29 | + * adjustment regardless of this setting. |
| 30 | + *<p> |
| 31 | + * Taking above into account, this feature is supported only by extension modules for |
| 32 | + * Joda and Java 8 date/time datatypes. |
| 33 | + *<p> |
| 34 | + * Feature used to be one of {@link tools.jackson.databind.DeserializationFeature}s |
| 35 | + * in Jackson 2.x but was moved here in 3.0. |
| 36 | + */ |
| 37 | + ADJUST_DATES_TO_CONTEXT_TIME_ZONE(true), |
| 38 | + |
15 | 39 | /**
|
16 | 40 | * Feature that controls whether stringified numbers (Strings that without
|
17 | 41 | * quotes would be legal JSON Numbers) may be interpreted as
|
@@ -51,6 +75,25 @@ public enum DateTimeFeature implements DatatypeFeature
|
51 | 75 | */
|
52 | 76 | ONE_BASED_MONTHS(true),
|
53 | 77 |
|
| 78 | + /** |
| 79 | + * Feature that controls whether numeric timestamp values are expected |
| 80 | + * to be written using nanosecond timestamps (enabled) or not (disabled), |
| 81 | + * <b>if and only if</b> datatype supports such resolution. |
| 82 | + * Only newer datatypes (such as Java8 Date/Time) support such resolution -- |
| 83 | + * older types (pre-Java8 <b>java.util.Date</b> etc) and Joda do not -- |
| 84 | + * and this setting <b>has no effect</b> on such types. |
| 85 | + *<p> |
| 86 | + * If disabled, standard millisecond timestamps are assumed. |
| 87 | + * This is the counterpart to {@link DateTimeFeature#WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS}. |
| 88 | + *<p> |
| 89 | + * Feature used to be one of {@link tools.jackson.databind.DeserializationFeature}s |
| 90 | + * in Jackson 2.x but was moved here in 3.0. |
| 91 | + *<p> |
| 92 | + * Feature is enabled by default, to support most accurate time values possible (where |
| 93 | + * available). |
| 94 | + */ |
| 95 | + READ_DATE_TIMESTAMPS_AS_NANOSECONDS(true), |
| 96 | + |
54 | 97 | /**
|
55 | 98 | * Feature that determines whether the {@link java.util.TimeZone} of the
|
56 | 99 | * {@link tools.jackson.databind.DeserializationContext} is used
|
@@ -113,7 +156,7 @@ public enum DateTimeFeature implements DatatypeFeature
|
113 | 156 | * and this setting <b>has no effect</b> on such types.
|
114 | 157 | *<p>
|
115 | 158 | * If disabled, standard millisecond timestamps are assumed.
|
116 |
| - * This is the counterpart to {@link DeserializationFeature#READ_DATE_TIMESTAMPS_AS_NANOSECONDS}. |
| 159 | + * This is the counterpart to {@link DateTimeFeature#READ_DATE_TIMESTAMPS_AS_NANOSECONDS}. |
117 | 160 | *<p>
|
118 | 161 | * Feature used to be one of {@link tools.jackson.databind.SerializationFeature}s
|
119 | 162 | * in Jackson 2.x but was moved here in 3.0.
|
|
0 commit comments