Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 5
    Fine answer. I tend to prefer ZonedDateTime.withEarlierOffsetAtOverlap() and ZonedDateTime.withLaterOffsetAtOverlap() for controlling which instance of 2 AM to get. There’s more than one way. Commented Feb 17 at 19:00
  • 1
    @Anonymous I didn't know that method! Thanks for pointing that out. I think even if I did know that, I would not have thought of this approach of first creating an "incorrect" value, then correcting it. Commented Feb 17 at 19:18
  • 1
    It depends, of course. If one knows the correct offset for sure, your way has the advantage of not taking the detour. Commented Feb 18 at 2:43
  • 1
    @SoT We don’t know what “your case” is. You have not explained your context at all. If you have not thought about edge cases like this, perhaps now is a good time to think. Commented Feb 18 at 7:01
  • 1
    @SoT You specified yourself ZoneOffset.of( "+01:00" ), so I had assumed that that was correct. You should know. I can’t know. Commented Feb 18 at 9:17