Skip to content

Why LocalDateDeserializer used UTC ? #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ChaceYang opened this issue Jul 10, 2019 · 5 comments
Closed

Why LocalDateDeserializer used UTC ? #119

ChaceYang opened this issue Jul 10, 2019 · 5 comments

Comments

@ChaceYang
Copy link

Why LocalDateDeserializer used UTC?
Closed issue LocalDateDeserializer ignores local time zone

JDK use system default zone.

    public static LocalDateTime now() {
        return now(Clock.systemDefaultZone());
    }

    public static LocalDateTime now(Clock clock) {
        Objects.requireNonNull(clock, "clock");
        Instant now = clock.instant();
        ZoneOffset offset = clock.getZone().getRules().getOffset(now);
        return ofEpochSecond(now.getEpochSecond(), now.getNano(), offset);
    }

Maybe LocalDateDeserializer used UTC is worst?

@cowtowncoder
Copy link
Member

What exactly is your problem here? Jackson defaults to UTC for most things, and "local" dates/times mean that there is NO TIMEZONE associated at all:

https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html

so one SHOULD NOT USE timezone with LocalDateTime and others, nor expect specific one, nor make any other assumptions.

@GedMarc
Copy link

GedMarc commented Jul 11, 2019

Correct, for zoning use ZonedDateTime and pull it back to LocalDate with a .asDate() to correctly shift between zones.

LocalDateTime and LocalDate are always in UTC, and this is correct. Please do not change this at all!

@funcfoo Perhaps look at your requirements and verify if you are using the correct objects.
@cowtowncoder Is there a ZonedDateTime serializer that takes a ZoneId as a parameter?

@ChaceYang
Copy link
Author

@cowtowncoder @GedMarc
LocalDateTime and LocalDate is NO TIMEZONE associated.
I agree with this.

so. I think is user defined.
we can be setting it in properties.

@ChaceYang
Copy link
Author

English is not my first language.

I'm not sure whether I make myself clear.

Long time passed. so I close this issue.

@cowtowncoder
Copy link
Member

I think that I understood enough to try to explain why I think handling is reasonable at this point, and that user needs to handle TimeZone separately from deserialization.
So I don't think I want to change handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants