question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ObjectMapper default timezone is GMT, should be UTC

See original GitHub issue

ObjectMapper is configured with GMT timezone:

protected final static BaseSettings DEFAULT_BASE = new BaseSettings(
            null, // can not share global ClassIntrospector any more (2.5+)
            DEFAULT_ANNOTATION_INTROSPECTOR,
            STD_VISIBILITY_CHECKER, null, TypeFactory.defaultInstance(),
            null, StdDateFormat.instance, null,
            Locale.getDefault(),
//            TimeZone.getDefault()
            TimeZone.getTimeZone("GMT"),  // <= HERE
            Base64Variants.getDefaultVariant() // 2.1
    );

(it’s on line 280)

But on many places in documentation and even in javadoc it’s written that it’s configured with UTC timezone. It is even cleaner to use UTC.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cowtowncodercommented, Apr 3, 2017

@cemo thank you for asking a good question: sometimes there are no good reasons, or reasons seem less convincing than what I thought.

0reactions
cemocommented, Apr 3, 2017

Thanks for great explanation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ObjectMapper default timezone is GMT, should be UTC #915
Changed for 2.7.0 so that default TimeZone for core jackson-databind is now UTC, consistently. No apparent breakage wrt unit tests.
Read more >
Default timezone for DateTime deserialization with Jackson ...
So, to answer your question about time zones, it sounds like by default Jackson always serializes using UTC (no time zone offset) which...
Read more >
Jackson Date - Baeldung
It's important to note that Jackson will serialize the Date to a timestamp format by default (number of milliseconds since January 1st, 1970, ......
Read more >
com.fasterxml.jackson.databind.ObjectMapper.setTimeZone ...
Method for overriding default TimeZone to use for formatting. Default value used is UTC (NOT default TimeZone of JVM). Popular methods of ObjectMapper....
Read more >
Handling Timezones in a Spring Boot Application - Reflectoring
You can change the database time zone manually but Oracle recommends that you keep it as UTC (the default) to avoid data conversion...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found