Skip to content

Configurable default timezone #719

Description

@sdavids

#651

This change is beneficial depending on the use case.

In a different scenario, this may not be advisable. For example, if an application has two nodes in different geographical locations:

Server A in location L in timezone X
Server B in location M in timezone Y

The date may be parsed differently depending on the server.

It would be beneficial to specify the timezone to be used. This could be done via a Java system property, environment variable, explicit parameter in the API or a configuration context object.

Activity

  1. drewnoakes commented on Apr 19, 2026

    @drewnoakes
    Owner

    Can you use TimeZone.setDefault, or start your JVM with -Duser.timezone=?

  2. Nadahar commented on Apr 19, 2026

    @Nadahar
    Contributor

    Can you use TimeZone.setDefault, or start your JVM with -Duser.timezone=?

    That is a terrible "solution", it applies JVM-wide, isn't thread-safe and doesn't allow dealing with more than one timezone at a time.

    IMO TimeZone and Locale should have been part of the mythical "context object" that could be passed around to methods that need it.

  3. drewnoakes commented on Apr 19, 2026

    @drewnoakes
    Owner

    Agree completely, but that context object doesn't exist yet and the original question asked for something at the process level.

  4. syskin345 commented on May 15, 2026

    @syskin345

    Would it be possible to extend the API so that we have an alternative way of extracting dates, using something better than ancient java.util.Date objects?

    java.util.Date is both inappropriate for "known date-time-components in unknown timezone" like here, since it just wraps a unix timestamp, but it also loses timezone information when it is present...

    And I mention this here because if API needs changing (to be configurable), maybe this is a better change. It would allow us to know that the answer has unknown timezone and it would be up to us to assume anything we want about it.

    [edit] but please don't delay with some solution because at this point I just cannot use the latest version if I require same answer regardless of environment. I can't even subtract the offset back to UTC myself because I don't know if the system default was applied or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions