Skip to content

Commit 06da5d4

Browse files
committed
1 parent 03a3b55 commit 06da5d4

File tree

5 files changed

+39
-51
lines changed

5 files changed

+39
-51
lines changed

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Project: jackson-databind
1414
(reported by Miles K)
1515
#497: Add new JsonInclude.Include feature to exclude maps after exclusion removes all elements
1616
#819: Add support for setting `FormatFeature` via `ObjectReader`, `ObjectWriter`
17+
#915: ObjectMapper default timezone is GMT, should be UTC
18+
(suggested by Infrag@github)
1719
#918: Add `MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING`
1820
(contributed by David H)
1921
#924: `SequenceWriter.writeAll()` could accept `Iterable`

src/main/java/com/fasterxml/jackson/databind/SequenceWriter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ public SequenceWriter writeAll(Object[] value) throws IOException
196196
return this;
197197
}
198198

199-
@Deprecated
200-
public <C extends Collection<?>> SequenceWriter writeAll(C container) throws IOException
201-
{
199+
// NOTE: redundant wrt variant that takes Iterable, but can not remove or even
200+
// deprecate due to backwards-compatibility needs
201+
public <C extends Collection<?>> SequenceWriter writeAll(C container) throws IOException {
202202
for (Object value : container) {
203203
write(value);
204204
}

src/main/java/com/fasterxml/jackson/databind/cfg/BaseSettings.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public final class BaseSettings
3131
*/
3232
private static final TimeZone DEFAULT_TIMEZONE =
3333
// TimeZone.getDefault()
34-
/* [databind#915] 26-Sep-2015, tatu: Should be UTC, plan to change
35-
* it so for 2.7
34+
/* [databind#915] 05-Nov-2015, tatu: Changed to UTC, from earlier
35+
* baseline of GMT (up to 2.6)
3636
*/
37-
TimeZone.getTimeZone("GMT");
37+
TimeZone.getTimeZone("UTC");
3838

3939
/*
4040
/**********************************************************

src/main/java/com/fasterxml/jackson/databind/util/ISO8601Utils.java

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,36 @@
1414
*/
1515
public class ISO8601Utils
1616
{
17-
/**
18-
* ID to represent the 'GMT' string
19-
*/
17+
@Deprecated // since 2.7
2018
private static final String GMT_ID = "GMT";
2119

2220
/**
23-
* @since 2.6
21+
* ID to represent the 'UTC' string, default timezone since Jackson 2.7
22+
*
23+
* @since 2.7
2424
*/
25-
// private static final String UTC_ID = "UTC";
25+
private static final String UTC_ID = "UTC";
2626

2727
/**
2828
* The GMT timezone, prefetched to avoid more lookups.
29+
*
30+
* @deprecated Since 2.7 use {@link #TIMEZONE_UTC} instead
2931
*/
32+
@Deprecated
3033
private static final TimeZone TIMEZONE_GMT = TimeZone.getTimeZone(GMT_ID);
3134

3235
/**
3336
* The UTC timezone, prefetched to avoid more lookups.
3437
*
35-
* @since 2.6
38+
* @since 2.7
3639
*/
37-
// private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone(UTC_ID);
40+
private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone(UTC_ID);
3841

3942
/**
40-
* Timezone we use for 'Z' in ISO-8601 date/time values.
43+
* Timezone we use for 'Z' in ISO-8601 date/time values: since 2.7
44+
* {@link #TIMEZONE_UTC}; with earlier versions up to 2.7 was {@link #TIMEZONE_GMT}.
4145
*/
42-
private static final TimeZone TIMEZONE_Z = TIMEZONE_GMT;
46+
private static final TimeZone TIMEZONE_Z = TIMEZONE_UTC;
4347

4448
/*
4549
/**********************************************************
@@ -64,13 +68,13 @@ public static TimeZone timeZoneGMT() {
6468
*/
6569

6670
/**
67-
* Format a date into 'yyyy-MM-ddThh:mm:ssZ' (GMT timezone, no milliseconds precision)
71+
* Format a date into 'yyyy-MM-ddThh:mm:ssZ' (default timezone, no milliseconds precision)
6872
*
6973
* @param date the date to format
7074
* @return the date formatted as 'yyyy-MM-ddThh:mm:ssZ'
7175
*/
7276
public static String format(Date date) {
73-
return format(date, false, TIMEZONE_GMT);
77+
return format(date, false, TIMEZONE_UTC);
7478
}
7579

7680
/**
@@ -81,15 +85,15 @@ public static String format(Date date) {
8185
* @return the date formatted as 'yyyy-MM-ddThh:mm:ss[.sss]Z'
8286
*/
8387
public static String format(Date date, boolean millis) {
84-
return format(date, millis, TIMEZONE_GMT);
88+
return format(date, millis, TIMEZONE_UTC);
8589
}
8690

8791
/**
8892
* Format date into yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]
8993
*
9094
* @param date the date to format
9195
* @param millis true to include millis precision otherwise false
92-
* @param tz timezone to use for the formatting (GMT will produce 'Z')
96+
* @param tz timezone to use for the formatting (UTC will produce 'Z')
9397
* @return the date formatted as yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]
9498
*/
9599
public static String format(Date date, boolean millis, TimeZone tz) {
@@ -243,9 +247,14 @@ public static Date parse(String date, ParsePosition pos) throws ParseException {
243247
timezone = TIMEZONE_Z;
244248
} else {
245249
// 18-Jun-2015, tatu: Looks like offsets only work from GMT, not UTC...
246-
// not sure why, but it is what it is.
247-
String timezoneId = GMT_ID + timezoneOffset;
250+
// not sure why, but that's the way it looks. Further, Javadocs for
251+
// `java.util.TimeZone` specifically instruct use of GMT as base for
252+
// custom timezones... odd.
253+
String timezoneId = "GMT" + timezoneOffset;
254+
// String timezoneId = "UTC" + timezoneOffset;
255+
248256
timezone = TimeZone.getTimeZone(timezoneId);
257+
249258
String act = timezone.getID();
250259
if (!act.equals(timezoneId)) {
251260
/* 22-Jan-2015, tatu: Looks like canonical version has colons, but we may be given

src/main/java/com/fasterxml/jackson/databind/util/StdDateFormat.java

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class StdDateFormat
3535

3636
/**
3737
* Same as 'regular' 8601, but handles 'Z' as an alias for "+0000"
38-
* (or "GMT")
38+
* (or "UTC")
3939
*/
4040
protected final static String DATE_FORMAT_STR_ISO8601_Z = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
4141

@@ -61,11 +61,12 @@ public class StdDateFormat
6161
};
6262

6363
/**
64-
* By default we use GMT for everything.
64+
* By default we use UTC for everything, with Jackson 2.7 and later
65+
* (2.6 and earlier relied on GMT)
6566
*/
6667
private final static TimeZone DEFAULT_TIMEZONE;
6768
static {
68-
DEFAULT_TIMEZONE = TimeZone.getTimeZone("GMT");
69+
DEFAULT_TIMEZONE = TimeZone.getTimeZone("UTC"); // since 2.7
6970
}
7071

7172
private final static Locale DEFAULT_LOCALE = Locale.US;
@@ -82,7 +83,7 @@ public class StdDateFormat
8283
* actual instances more cheaply (avoids re-parsing).
8384
*/
8485
static {
85-
/* Another important thing: let's force use of GMT for
86+
/* Another important thing: let's force use of default timezone for
8687
* baseline DataFormat objects
8788
*/
8889

@@ -170,18 +171,6 @@ public StdDateFormat clone() {
170171
return new StdDateFormat(_timezone, _locale);
171172
}
172173

173-
/**
174-
* Method for getting the globally shared DateFormat instance
175-
* that uses GMT timezone and can handle simple ISO-8601
176-
* compliant date format.
177-
*
178-
* @deprecated Since 2.4 not to be used.
179-
*/
180-
@Deprecated
181-
public static DateFormat getBlueprintISO8601Format() {
182-
return DATE_FORMAT_ISO8601;
183-
}
184-
185174
/**
186175
* @deprecated Since 2.4; use variant that takes Locale
187176
*/
@@ -200,18 +189,6 @@ public static DateFormat getISO8601Format(TimeZone tz) {
200189
public static DateFormat getISO8601Format(TimeZone tz, Locale loc) {
201190
return _cloneFormat(DATE_FORMAT_ISO8601, DATE_FORMAT_STR_ISO8601, tz, loc);
202191
}
203-
204-
/**
205-
* Method for getting the globally shared DateFormat instance
206-
* that uses GMT timezone and can handle RFC-1123
207-
* compliant date format.
208-
*
209-
* @deprecated Since 2.4 not to be used.
210-
*/
211-
@Deprecated
212-
public static DateFormat getBlueprintRFC1123Format() {
213-
return DATE_FORMAT_RFC1123;
214-
}
215192

216193
/**
217194
* Method for getting a non-shared DateFormat instance
@@ -367,9 +344,9 @@ protected Date parseAsISO8601(String dateStr, ParsePosition pos)
367344
* timezone modifiers for ISO-8601. So we need to do some scrubbing.
368345
*/
369346

370-
/* First: do we have "zulu" format ('Z' == "GMT")? If yes, that's
347+
/* First: do we have "zulu" format ('Z' == "UTC")? If yes, that's
371348
* quite simple because we already set date format timezone to be
372-
* GMT, and hence can just strip out 'Z' altogether
349+
* UTC, and hence can just strip out 'Z' altogether
373350
*/
374351
int len = dateStr.length();
375352
char c = dateStr.charAt(len-1);

0 commit comments

Comments
 (0)