Class JavaTimeConverters


  • @Deprecated
    public class JavaTimeConverters
    extends java.lang.Object
    Deprecated.
    This API is ICU internal only.
    This class provides utility methods for converting between Java 8's 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 Detail

    • Constructor Detail

      • JavaTimeConverters

        private JavaTimeConverters()
        Deprecated.
    • Method Detail

      • temporalToCalendar

        @Deprecated
        public static Calendar temporalToCalendar​(java.time.ZonedDateTime dateTime)
        Deprecated.
        This API is ICU internal only.
        Converts a ZonedDateTime to a Calendar.

        This method creates a Calendar instance that represents the same date and time as the specified ZonedDateTime, taking into account the time zone information associated with the ZonedDateTime.

        Parameters:
        dateTime - The ZonedDateTime to convert.
        Returns:
        A Calendar instance representing the same date and time as the specified ZonedDateTime, with the time zone set accordingly.
      • temporalToCalendar

        @Deprecated
        public static Calendar temporalToCalendar​(java.time.OffsetTime time)
        Deprecated.
        This API is ICU internal only.
        Converts an OffsetTime to a Calendar.

        This method creates a Calendar instance that represents the same time of day as the specified OffsetTime, taking into account the offset from UTC associated with the OffsetTime. The resulting Calendar will have its date components (year, month, day) set to the current date in the time zone represented by the offset.

        Parameters:
        time - The OffsetTime to convert.
        Returns:
        A Calendar instance representing the same time of day as the specified OffsetTime, with the time zone set accordingly and date components set to the current date in that time zone.
      • temporalToCalendar

        @Deprecated
        public static Calendar temporalToCalendar​(java.time.OffsetDateTime dateTime)
        Deprecated.
        This API is ICU internal only.
        Converts an OffsetDateTime to a Calendar.

        This method creates a Calendar instance that represents the same date and time as the specified OffsetDateTime, taking into account the offset from UTC associated with the OffsetDateTime.

        Parameters:
        dateTime - The OffsetDateTime to convert.
        Returns:
        A Calendar instance representing the same date and time as the specified OffsetDateTime, with the time zone set accordingly.
      • temporalToCalendar

        @Deprecated
        static Calendar temporalToCalendar​(java.time.chrono.ChronoLocalDate date)
        Deprecated.
        Converts a ChronoLocalDate to a Calendar.

        This method creates a Calendar instance that represents the same date as the specified ChronoLocalDate. The resulting Calendar will be in the default time zone of the JVM and will have its time components (hour, minute, second, millisecond) set to zero.

        Parameters:
        date - The ChronoLocalDate to convert.
        Returns:
        A Calendar instance representing the same date as the specified ChronoLocalDate, with time components set to zero.
      • temporalToCalendar

        @Deprecated
        public static Calendar temporalToCalendar​(java.time.LocalTime time)
        Deprecated.
        This API is ICU internal only.
        Converts a LocalTime to a Calendar.

        This method creates a Calendar instance that represents the same time of day as the specified LocalTime. The resulting Calendar will 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.

        Parameters:
        time - The LocalTime to convert.
        Returns:
        A Calendar instance representing the same time of day as the specified LocalTime, with date components set to the current date in the default time zone.
      • temporalToCalendar

        @Deprecated
        public static Calendar temporalToCalendar​(java.time.LocalDateTime dateTime)
        Deprecated.
        This API is ICU internal only.
        Converts a ChronoLocalDateTime to a Calendar.

        This method creates a Calendar instance that represents the same date and time as the specified ChronoLocalDateTime. The resulting Calendar will be in the default time zone of the JVM.

        Parameters:
        dateTime - The ChronoLocalDateTime to convert.
        Returns:
        A Calendar instance representing the same date and time as the specified ChronoLocalDateTime.
      • temporalToCalendar

        @Deprecated
        public static Calendar temporalToCalendar​(java.time.temporal.Temporal temp)
        Deprecated.
        This API is ICU internal only.
        Converts a Temporal to a Calendar.
        Parameters:
        temp - The Temporal to convert.
        Returns:
        A Calendar instance representing the same date and time as the specified Temporal.
      • zoneIdToTimeZone

        @Deprecated
        public static TimeZone zoneIdToTimeZone​(java.time.ZoneId zoneId)
        Deprecated.
        This API is ICU internal only.
        Converts a ZoneId to a TimeZone.

        This method creates a TimeZone from the specified ZoneId. The resulting TimeZone will represent the time zone rules associated with the given ZoneId.

        Parameters:
        zoneId - The zone ID to convert.
        Returns:
        A TimeZone representing the time zone rules associated with the given ZoneId.
      • zoneOffsetToTimeZone

        @Deprecated
        public static TimeZone zoneOffsetToTimeZone​(java.time.ZoneOffset zoneOffset)
        Deprecated.
        This API is ICU internal only.
        Converts a ZoneOffset to a TimeZone.

        This method creates a TimeZone that has a fixed offset from UTC, represented by the given ZoneOffset.

        Parameters:
        zoneOffset - The zone offset to convert.
        Returns:
        A TimeZone that has a fixed offset from UTC, represented by the given ZoneOffset.
      • millisToCalendar

        private static Calendar millisToCalendar​(long epochMillis)
        Deprecated.
      • millisToCalendar

        private static Calendar millisToCalendar​(long epochMillis,
                                                 TimeZone timeZone)
        Deprecated.