Package com.atlassian.jira.datetime
Class DateTimeConverter
java.lang.Object
com.atlassian.jira.datetime.DateTimeConverter
-
Method Summary
Modifier and TypeMethodDescriptionstatic ZonedDateTimeConverts a Date to a ZonedDateTime at midnight in an inferred fixed offset timezone.
-
Method Details
-
inferOffsetFromLocalMidnightDate
Converts a Date to a ZonedDateTime at midnight in an inferred fixed offset timezone. The fixed offset is determined by calculating the likely UTC offset from the original date, assuming it was created at midnight in some timezone.This method is designed to handle dates that were stored as timestamps at midnight in a user's timezone. When these timestamps are read back as UTC Date objects, this method infers the timezone offset of the original date from the hour component. This preserves the original date as intended by the user (JRASERVER-76438).
For example, if a date was stored as "2023-01-01 00:00:00" in UTC+5, it would be stored as "2022-12-31 19:00:00" in UTC. This method would convert it back to "2023-01-01 00:00:00" in UTC+5.
This will always return a date with an offset in the range between UTC-10 (inclusive) and UTC+14 (exclusive). This range is used as it tends to provide the more commonly-used zone where there is ambiguity.- Parameters:
date- the date to convert, nullable- Returns:
- a ZonedDateTime at midnight in the original timezone, or null if input was null
-