java.lang.Object
org.litebridge.commons.TimeUtils
Utility class for converting and formatting date and time objects.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringFormats the given temporal object using the specified pattern.static @Nullable Datestatic @Nullable DatetoDate(@Nullable LocalDateTime localDateTime) Converts aLocalDateTimeto aDatein the system default time zone.static @Nullable DatetoDate(@Nullable ZonedDateTime zonedDateTime) Converts aZonedDateTimeto aDate.static @Nullable LocalDatetoLocalDate(@Nullable String dateStr) Converts a date string to aLocalDate.static @Nullable LocalDatetoLocalDate(@Nullable ZonedDateTime zonedDateTime) Converts aZonedDateTimeto aLocalDate.static @Nullable LocalDateTimetoLocalDateTime(@Nullable String dateStr) Converts a date-time string to aLocalDateTime.static @Nullable LocalDateTimetoLocalDateTime(@Nullable ZonedDateTime zonedDateTime) Converts aZonedDateTimeto aLocalDateTimein the system default time zone.static @Nullable ZonedDateTimetoZonedDateTime(@Nullable String dateStr) Converts a date-time string to aZonedDateTime.static @Nullable ZonedDateTimetoZonedDateTime(@Nullable LocalDate localDate) Converts aLocalDateto aZonedDateTimeat the start of the day in the system default time zone.static @Nullable ZonedDateTimetoZonedDateTime(@Nullable LocalDateTime localDateTime) Converts aLocalDateTimeto aZonedDateTimeusing the system default time zone.static @Nullable ZonedDateTimetoZonedDateTime(@Nullable Date requestedDate) Converts aDateto aZonedDateTimeusing the system default time zone.
-
Method Details
-
toZonedDateTime
Converts a date-time string to aZonedDateTime.- Parameters:
dateStr- the date-time string to parse; may be null- Returns:
- the parsed
ZonedDateTime, ornullifdateStris null
-
toZonedDateTime
Converts aDateto aZonedDateTimeusing the system default time zone.- Parameters:
requestedDate- the date to convert; may be null- Returns:
- the corresponding
ZonedDateTime, ornullifrequestedDateis null
-
toZonedDateTime
Converts aLocalDateTimeto aZonedDateTimeusing the system default time zone.- Parameters:
localDateTime- the local date-time to convert; may be null- Returns:
- the corresponding
ZonedDateTime, ornulliflocalDateTimeis null
-
toZonedDateTime
Converts aLocalDateto aZonedDateTimeat the start of the day in the system default time zone.- Parameters:
localDate- the local date to convert; may be null- Returns:
- the corresponding
ZonedDateTime, ornulliflocalDateis null
-
toDate
Converts aZonedDateTimeto aDate.- Parameters:
zonedDateTime- the zoned date-time to convert; may be null- Returns:
- the corresponding
Date, ornullifzonedDateTimeis null
-
toDate
- Parameters:
localDate- the local date to convert; may be null- Returns:
- the corresponding
Date, ornulliflocalDateis null
-
toDate
Converts aLocalDateTimeto aDatein the system default time zone.- Parameters:
localDateTime- the local date-time to convert; may be null- Returns:
- the corresponding
Date, ornulliflocalDateTimeis null
-
toLocalDate
Converts aZonedDateTimeto aLocalDate.- Parameters:
zonedDateTime- the zoned date-time to convert; may be null- Returns:
- the corresponding
LocalDate, ornullifzonedDateTimeis null
-
toLocalDate
Converts a date string to aLocalDate.- Parameters:
dateStr- the date string to parse; may be null- Returns:
- the parsed
LocalDate, ornullifdateStris null
-
toLocalDateTime
Converts aZonedDateTimeto aLocalDateTimein the system default time zone.- Parameters:
zonedDateTime- the zoned date-time to convert; may be null- Returns:
- the corresponding
LocalDateTime, ornullifzonedDateTimeis null
-
toLocalDateTime
Converts a date-time string to aLocalDateTime.- Parameters:
dateStr- the date-time string to parse; may be null- Returns:
- the parsed
LocalDateTime, ornullifdateStris null
-
format
Formats the given temporal object using the specified pattern.- Parameters:
dateToFormat- the temporal object to formatpattern- the pattern to use for formatting- Returns:
- the formatted date-time string
-