Class TemporalAdapter<T extends Temporal>

  • Type Parameters:
    T - A concrete implementation of Temporal
    All Implemented Interfaces:
    Serializable

    public class TemporalAdapter<T extends Temporal>
    extends Object
    implements Serializable
    The iCalendar specification supports multiple representations of date/time values, as outlined below. This class encapsulates a Temporal value and provides support for all corresponding representations in the specification. The recommended Temporal implementations for use with iCal4j are as follows:
    • LocalDate - represents an iCalendar DATE value as defined in section 3.3.4 of RFC5545
    • LocalDateTime - represents an iCalendar FORM #1: DATE-TIME value as defined in section 3.3.5 of RFC5545
    • Instant - represents an iCalendar FORM #2: DATE-TIME value as defined in section 3.3.5 of RFC5545
    • ZonedDateTime - represents an iCalendar FORM #3: DATE-TIME value as defined in section 3.3.5 of RFC5545
    Note that a local (i.e. floating) temporal type is used we need to apply a ZoneId for calculations such as recurrence inclusions and other date-based comparisons. Use isFloating(Temporal) to determine floating instances.
    See Also:
    Serialized Form
    • Constructor Detail

      • TemporalAdapter

        public TemporalAdapter​(T temporal)
      • TemporalAdapter

        public TemporalAdapter​(T temporal,
                               TimeZoneRegistry timeZoneRegistry)
    • Method Detail

      • getTemporal

        public T getTemporal()
      • parse

        public static TemporalAdapter<ZonedDateTime> parse​(String value,
                                                           ZoneId zoneId)
        Parse a string representation of a temporal value applicable to the specified timezone.
        Parameters:
        value - a string representing a floating temporal value
        zoneId - a timezone applied to the parsed value
        Returns:
        an adapter containing the parsed temporal value
        Throws:
        DateTimeParseException - if the string cannot be parsed
      • parse

        public static TemporalAdapter<ZonedDateTime> parse​(String value,
                                                           TzId tzId)
        Parse a string representation of a temporal value applicable to the specified timezone.
        Parameters:
        value - a string representing a floating temporal value
        tzId - a timezone applied to the parsed value
        Returns:
        an adapter containing the parsed temporal value
        Throws:
        DateTimeParseException - if the string cannot be parsed
      • parse

        public static TemporalAdapter<ZonedDateTime> parse​(String value,
                                                           TzId tzId,
                                                           TimeZoneRegistry timeZoneRegistry)
        Parameters:
        value - a string representing a floating temporal value
        tzId - a timezone applied to the parsed value
        timeZoneRegistry - timezone definitions
        Returns:
      • from

        public static TemporalAdapter from​(Date date)
        This method provides support for conversion of legacy Date and DateTime instances to temporal values.
        Parameters:
        date - a date/time instance
        Returns:
        a temporal adapter instance equivalent to the specified date/time value
      • isFloating

        public static boolean isFloating​(Temporal date)
        Indicates whether the temporal type represents a "floating" date/time value.
        Returns:
        true if the temporal type is floating, otherwise false
      • isUtc

        public static boolean isUtc​(Temporal date)
        Indicates whether the temporal type represents a UTC date/time value.
        Returns:
        true if the temporal type is in UTC time, otherwise false
      • isBefore

        public static <T extends Temporal> boolean isBefore​(T date1,
                                                            T date2)
      • isAfter

        public static <T extends Temporal> boolean isAfter​(T date1,
                                                           T date2)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object