Class JavaTimeConverters
java.time
classes and the Calendar and related classes from the
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longDeprecated.private static final longDeprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CalendarconvertCalendar(Calendar inputCalendar) Deprecated.This API is ICU internal only.static CalendarDeprecated.This API is ICU internal only.private static longDeprecated.private static CalendarmillisToCalendar(long epochMillis) Deprecated.private static CalendarmillisToCalendar(long epochMillis, TimeZone timeZone) Deprecated.static CalendarmonthToCalendar(Month month) Deprecated.This API is ICU internal only.private static longmonthToMilli(Month month) Deprecated.(package private) static CalendarDeprecated.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.
-
Field Details
-
MILLIS_PER_HOUR
private static final long MILLIS_PER_HOURDeprecated.- See Also:
-
MILLIS_PER_DAY
private static final long MILLIS_PER_DAYDeprecated.- See Also:
-
-
Constructor Details
-
JavaTimeConverters
private JavaTimeConverters()Deprecated.
-
-
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.Converts aChronoLocalDateto aCalendar.This method creates a
Calendarinstance that represents the same date as the specifiedChronoLocalDate. The resultingCalendarwill be in the default time zone of the JVM and will have its time components (hour, minute, second, millisecond) set to zero.- Parameters:
date- TheChronoLocalDateto convert.- Returns:
- A
Calendarinstance representing the same date as the specifiedChronoLocalDate, with time components set to zero.
-
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". -
millisToCalendar
Deprecated. -
millisToCalendar
-
dayOfWeekToMillis
Deprecated. -
monthToMilli
Deprecated. -
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.
-