Package net.fortuna.ical4j.model
Class TemporalAdapter<T extends Temporal>
- java.lang.Object
-
- net.fortuna.ical4j.model.TemporalAdapter<T>
-
- Type Parameters:
T
- A concrete implementation ofTemporal
- 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 aTemporal
value and provides support for all corresponding representations in the specification. The recommendedTemporal
implementations for use with iCal4j are as follows:LocalDate
- represents an iCalendar DATE value as defined in section 3.3.4 of RFC5545LocalDateTime
- represents an iCalendar FORM #1: DATE-TIME value as defined in section 3.3.5 of RFC5545Instant
- represents an iCalendar FORM #2: DATE-TIME value as defined in section 3.3.5 of RFC5545ZonedDateTime
- represents an iCalendar FORM #3: DATE-TIME value as defined in section 3.3.5 of RFC5545
ZoneId
for calculations such as recurrence inclusions and other date-based comparisons. UseisFloating(Temporal)
to determine floating instances.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TemporalAdapter(TemporalAdapter<T> adapter)
TemporalAdapter(T temporal)
TemporalAdapter(T temporal, TimeZoneRegistry timeZoneRegistry)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
static TemporalAdapter<?>
from(Date date)
T
getTemporal()
int
hashCode()
static <T extends Temporal>
booleanisAfter(T date1, T date2)
static <T extends Temporal>
booleanisBefore(T date1, T date2)
static boolean
isDateTimePrecision(Temporal date)
Indicates whether the temporal type represents a date/time value.static boolean
isFloating(Temporal date)
Indicates whether the temporal type represents a "floating" date/time value.static boolean
isUtc(Temporal date)
Indicates whether the temporal type represents a UTC date/time value.static <T extends Temporal>
TemporalAdapter<T>parse(String value)
Parse a string representation of a temporal value.static TemporalAdapter<ZonedDateTime>
parse(String value, ZoneId zoneId)
Parse a string representation of a temporal value applicable to the specified timezone.static <T extends Temporal>
TemporalAdapter<T>parse(String value, CalendarDateFormat parseFormat)
static TemporalAdapter<ZonedDateTime>
parse(String value, TzId tzId)
Parse a string representation of a temporal value applicable to the specified timezone.static TemporalAdapter<ZonedDateTime>
parse(String value, TzId tzId, TimeZoneRegistry timeZoneRegistry)
ZonedDateTime
toLocalTime()
static ZonedDateTime
toLocalTime(Temporal temporal, ZoneId zoneId)
ZonedDateTime
toLocalTime(ZoneId zoneId)
String
toString()
String
toString(ZoneId zoneId)
-
-
-
Constructor Detail
-
TemporalAdapter
public TemporalAdapter(TemporalAdapter<T> adapter)
-
TemporalAdapter
public TemporalAdapter(T temporal)
-
TemporalAdapter
public TemporalAdapter(T temporal, TimeZoneRegistry timeZoneRegistry)
-
-
Method Detail
-
getTemporal
public T getTemporal()
-
toLocalTime
public ZonedDateTime toLocalTime()
-
toLocalTime
public ZonedDateTime toLocalTime(ZoneId zoneId)
-
toLocalTime
public static ZonedDateTime toLocalTime(Temporal temporal, ZoneId zoneId)
-
parse
public static <T extends Temporal> TemporalAdapter<T> parse(String value) throws DateTimeParseException
Parse a string representation of a temporal value.- Parameters:
value
- a string representing a temporal- Returns:
- an adapter containing the parsed temporal value and format type
- Throws:
DateTimeParseException
- if the string cannot be parsed
-
parse
public static <T extends Temporal> TemporalAdapter<T> parse(String value, CalendarDateFormat parseFormat) throws DateTimeParseException
- Throws:
DateTimeParseException
-
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 valuezoneId
- 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 valuetzId
- 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 valuetzId
- a timezone applied to the parsed valuetimeZoneRegistry
- timezone definitions- Returns:
-
from
public static TemporalAdapter<?> from(Date date)
This method provides support for conversion of legacyDate
andDateTime
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
-
isDateTimePrecision
public static boolean isDateTimePrecision(Temporal date)
Indicates whether the temporal type represents a date/time value.- Returns:
- true if the temporal type has DATE-TIME precision, 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)
-
-