Class JavaTimeConverters
java.time
classes and the Calendar and related classes from the
org.graalvm.shadowed.com.ibm.icu.util package.
The class includes methods for converting various temporal types, such as
ZonedDateTime, OffsetTime, OffsetDateTime, LocalTime,
ChronoLocalDate, and ChronoLocalDateTime, to Calendar instances.
Additionally, it provides methods to convert between ZoneId and TimeZone, and
ZoneOffset and TimeZone.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CalendarconvertCalendar(Calendar inputCalendar) Deprecated.This API is ICU internal only.static CalendarDeprecated.This API is ICU internal only.static CalendarmonthToCalendar(Month month) Deprecated.This API is ICU internal only.static CalendartemporalToCalendar(LocalDateTime dateTime) Deprecated.This API is ICU internal only.static CalendartemporalToCalendar(LocalTime time) Deprecated.This API is ICU internal only.static CalendartemporalToCalendar(OffsetDateTime dateTime) Deprecated.This API is ICU internal only.static CalendartemporalToCalendar(OffsetTime time) Deprecated.This API is ICU internal only.static CalendartemporalToCalendar(Temporal temp) Deprecated.This API is ICU internal only.static CalendartemporalToCalendar(ZonedDateTime dateTime) Deprecated.This API is ICU internal only.static TimeZonezoneIdToTimeZone(ZoneId zoneId) Deprecated.This API is ICU internal only.static TimeZonezoneOffsetToTimeZone(ZoneOffset zoneOffset) Deprecated.This API is ICU internal only.
-
Method Details
-
temporalToCalendar
Deprecated.This API is ICU internal only.Converts aZonedDateTimeto aCalendar.This method creates a
Calendarinstance that represents the same date and time as the specifiedZonedDateTime, taking into account the time zone information associated with theZonedDateTime.- Parameters:
dateTime- TheZonedDateTimeto convert.- Returns:
- A
Calendarinstance representing the same date and time as the specifiedZonedDateTime, with the time zone set accordingly.
-
temporalToCalendar
Deprecated.This API is ICU internal only.Converts anOffsetTimeto aCalendar.This method creates a
Calendarinstance that represents the same time of day as the specifiedOffsetTime, taking into account the offset from UTC associated with theOffsetTime. The resultingCalendarwill have its date components (year, month, day) set to the current date in the time zone represented by the offset.- Parameters:
time- TheOffsetTimeto convert.- Returns:
- A
Calendarinstance representing the same time of day as the specifiedOffsetTime, with the time zone set accordingly and date components set to the current date in that time zone.
-
temporalToCalendar
Deprecated.This API is ICU internal only.Converts anOffsetDateTimeto aCalendar.This method creates a
Calendarinstance that represents the same date and time as the specifiedOffsetDateTime, taking into account the offset from UTC associated with theOffsetDateTime.- Parameters:
dateTime- TheOffsetDateTimeto convert.- Returns:
- A
Calendarinstance representing the same date and time as the specifiedOffsetDateTime, with the time zone set accordingly.
-
temporalToCalendar
Deprecated.This API is ICU internal only.Converts aLocalTimeto aCalendar.This method creates a
Calendarinstance that represents the same time of day as the specifiedLocalTime. The resultingCalendarwill be in the default time zone of the JVM and will have its date components (year, month, day) set to the current date in the default time zone. -
temporalToCalendar
Deprecated.This API is ICU internal only.Converts aChronoLocalDateTimeto aCalendar.This method creates a
Calendarinstance that represents the same date and time as the specifiedChronoLocalDateTime. The resultingCalendarwill be in the default time zone of the JVM.- Parameters:
dateTime- TheChronoLocalDateTimeto convert.- Returns:
- A
Calendarinstance representing the same date and time as the specifiedChronoLocalDateTime.
-
temporalToCalendar
-
zoneIdToTimeZone
-
zoneOffsetToTimeZone
Deprecated.This API is ICU internal only.Converts aZoneOffsetto aTimeZone.This method creates a
TimeZonethat has a fixed offset from UTC, represented by the givenZoneOffset.- Parameters:
zoneOffset- The zone offset to convert.- Returns:
- A
TimeZonethat has a fixed offset from UTC, represented by the givenZoneOffset.
-
dayOfWeekToCalendar
Deprecated.This API is ICU internal only.Converts aDayOfWeekto aCalendar.This method creates a
Calendarinstance that represents a day that is the same day of week as specified byDayOfWeek. It is set somewhere close to epoch time.Note: this should only be used to format if using a pattern or skeleton with a day of week field only. That means that
c-ccccccpatterns are recommended,E-EEEEEEande-eeeeeeare likely wrong (because they are not stand-alone). Anything else is clearly wrong. It does not make sense to format aDayOfWeekas"MMMM d, y". See}.invalid @link
{@link https://unicode.org/reports/tr35/tr35-dates.html#dfst-weekday -
monthToCalendar
Deprecated.This API is ICU internal only.Converts aMonthto aCalendar.This method creates a
Calendarinstance that represents the same month as specified byMonth. It is set somewhere close to epoch time.Note: this should only be used to format if using a pattern or skeleton with a day of month field only. That means that
L-LLLLLpatterns are recommended,E-MMMMMis likely wrong (because it is not stand-alone). Anything else is clearly wrong. It does not make sense to format aMonthas"MMMM d, y". See}.invalid @link
{@link https://unicode.org/reports/tr35/tr35-dates.html#dfst-monthNote: only use this method for the Gregorian calendar and related calendars, given that the
Monthdocumentation, states that theMonthenum "... may be used by any calendar system that has the month-of-year concept defined equivalent to the ISO-8601 calendar system". -
convertCalendar
Deprecated.This API is ICU internal only.- Parameters:
inputCalendar- The JDK Calendar to convert.- Returns:
- An ICU Calendar that has the same properties as the Java one.
-