Top Description Fields Constructors Methods
net.fortuna.ical4j.model

public Class TemporalAdapter<T extends Temporal>

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Type Parameters
<T>
A concrete implementation of Temporal
Imports
net.fortuna.ical4j.model.parameter.TzId, net.fortuna.ical4j.util.CompatibilityHints, .TimeZones, java.io.Serializable, java.time.*, java.time.chrono.ChronoZonedDateTime, java.time.format.DateTimeParseException, java.time.temporal.ChronoField, .Temporal, java.util.Objects

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: Note that where 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 TemporalAdapter#isFloating(Temporal) to determine floating instances.

Field Summary

Modifier and TypeField and Description
private transient volatile T
private final transient TimeZoneRegistry
timeZoneRegistry

Provides localized timezone definitions for an iCalendar object.

private final TzId
tzId

An iCalendar TzId parameter representing the ZoneId for a Temporal value.

private final String
valueString

The iCalendar-compliant string representation of a Temporal value.

Constructor Summary

AccessConstructor and Description
public
public
TemporalAdapter(T temporal)

public
TemporalAdapter(T temporal, TimeZoneRegistry timeZoneRegistry)

private
TemporalAdapter(String valueString)

private
TemporalAdapter(String
a string representation of a floating date/time value
value
,
TzId
a zone id to apply to the parsed value
tzId
)

Support lazy parsing of value string using a zone id to allow full initialisation of java.time.zone.ZoneRulesProvider instances.

private
TemporalAdapter(String
a string representation of a floating date/time value
value
,
TzId
a zone id to apply to the parsed value
tzId
,
TimeZoneRegistry
timezone definitions
timeZoneRegistry
)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public static TemporalAdapter<?>

Returns:

a temporal adapter instance equivalent to the specified date/time value
from
(Date
a date/time instance
date
)
References Deprecated Date is deprecated or references (maybe indirectly) at least one deprecated element.

This method provides support for conversion of legacy Date and DateTime instances to temporal values.

public T
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

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

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

public static boolean

Returns:

true if the temporal type has DATE-TIME precision, otherwise false
isDateTimePrecision
(Temporal date)

Indicates whether the temporal type represents a date/time value.

public static boolean

Returns:

true if the temporal type is floating, otherwise false
isFloating
(Temporal date)

Indicates whether the temporal type represents a "floating" date/time value.

public static boolean

Returns:

true if the temporal type is in UTC time, otherwise false
isUtc
(Temporal date)

Indicates whether the temporal type represents a UTC date/time value.

public static <T extends Temporal> TemporalAdapter<T>

Returns:

an adapter containing the parsed temporal value and format type
parse
(String
a string representing a temporal
value
)

Parse a string representation of a temporal value.

public static <T extends Temporal> TemporalAdapter<T>
parse(String value, CalendarDateFormat parseFormat)

public static TemporalAdapter<ZonedDateTime>

Returns:

an adapter containing the parsed temporal value
parse
(String
a string representing a floating temporal value
value
,
ZoneId
a timezone applied to the parsed value
zoneId
)

Parse a string representation of a temporal value applicable to the specified timezone.

public static TemporalAdapter<ZonedDateTime>

Returns:

an adapter containing the parsed temporal value
parse
(String
a string representing a floating temporal value
value
,
TzId
a timezone applied to the parsed value
tzId
)

Parse a string representation of a temporal value applicable to the specified timezone.

public static TemporalAdapter<ZonedDateTime>
parse(String
a string representing a floating temporal value
value
,
TzId
a timezone applied to the parsed value
tzId
,
TimeZoneRegistry
timezone definitions
timeZoneRegistry
)

private String

Returns:

a string
toInstantString
(T
a temporal value
temporal
)

Return an ISO8601 instant string for the specified temporal value.

public ZonedDateTime
public ZonedDateTime
public static ZonedDateTime
toLocalTime(Temporal temporal, ZoneId zoneId)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public String
toString(ZoneId zoneId)

private String
toString(T temporal)

private String

Returns:

a string
toString
(T
a temporal value
temporal
,
ZoneId
the overriding zone id for DATE-TIME instances
zoneId
)

Return a string representation of the given temporal value, using the specified zone ID for applicable values (i.e. values that support the DATE-TIME format).

private String
toString(CalendarDateFormat format, T temporal)

private String
toString(CalendarDateFormat format, ZoneId zoneId, T temporal)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

temporalback to summary
private transient volatile T temporal
timeZoneRegistryback to summary
private final transient TimeZoneRegistry timeZoneRegistry

Provides localized timezone definitions for an iCalendar object.

tzIdback to summary
private final TzId tzId

An iCalendar TzId parameter representing the ZoneId for a Temporal value. This value may be localized to a specific iCalendar object, and thus is only meaningful when combined with a TimeZoneRegistry instance. If no registry is provided it is assumed this represents a global timezone identifier.

valueStringback to summary
private final String valueString

The iCalendar-compliant string representation of a Temporal value.

Constructor Detail

TemporalAdapterback to summary
public TemporalAdapter(TemporalAdapter<T> adapter)
TemporalAdapterback to summary
public TemporalAdapter(T temporal)
TemporalAdapterback to summary
public TemporalAdapter(T temporal, TimeZoneRegistry timeZoneRegistry)
TemporalAdapterback to summary
private TemporalAdapter(String valueString)
TemporalAdapterback to summary
private TemporalAdapter(String value, TzId tzId)

Support lazy parsing of value string using a zone id to allow full initialisation of java.time.zone.ZoneRulesProvider instances.

Parameters
value:String

a string representation of a floating date/time value

tzId:TzId

a zone id to apply to the parsed value

TemporalAdapterback to summary
private TemporalAdapter(String value, TzId tzId, TimeZoneRegistry timeZoneRegistry)
Parameters
value:String

a string representation of a floating date/time value

tzId:TzId

a zone id to apply to the parsed value

timeZoneRegistry:TimeZoneRegistry

timezone definitions

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
fromback to summary
public static TemporalAdapter<?> from(Date date)

References Deprecated

Date is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

This method provides support for conversion of legacy Date and DateTime instances to temporal values.

Parameters
date:Date

a date/time instance

Returns:TemporalAdapter<?>

a temporal adapter instance equivalent to the specified date/time value

Annotations
@SuppressWarnings:deprecation
getTemporalback to summary
public T getTemporal()
Annotations
@SuppressWarnings:unchecked
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isAfterback to summary
public static <T extends Temporal> boolean isAfter(T date1, T date2)
isBeforeback to summary
public static <T extends Temporal> boolean isBefore(T date1, T date2)
isDateTimePrecisionback to summary
public static boolean isDateTimePrecision(Temporal date)

Indicates whether the temporal type represents a date/time value.

Returns:boolean

true if the temporal type has DATE-TIME precision, otherwise false

isFloatingback to summary
public static boolean isFloating(Temporal date)

Indicates whether the temporal type represents a "floating" date/time value.

Returns:boolean

true if the temporal type is floating, otherwise false

isUtcback to summary
public static boolean isUtc(Temporal date)

Indicates whether the temporal type represents a UTC date/time value. A temporal is defined as UTC if it matches any of the following: - does not have associated zone information (e.g. Instant or OffsetDateTime) - where offset is supported the offset must be zero

Returns:boolean

true if the temporal type is in UTC time, otherwise false

parseback to summary
public static <T extends Temporal> TemporalAdapter<T> parse(String value) throws DateTimeParseException

Parse a string representation of a temporal value.

Parameters
value:String

a string representing a temporal

Returns:TemporalAdapter<T>

an adapter containing the parsed temporal value and format type

Exceptions
DateTimeParseException:
if the string cannot be parsed
parseback to summary
public static <T extends Temporal> TemporalAdapter<T> parse(String value, CalendarDateFormat parseFormat) throws DateTimeParseException
Annotations
@SuppressWarnings:unchecked
parseback to summary
public static TemporalAdapter<ZonedDateTime> parse(String value, ZoneId zoneId)

Parse a string representation of a temporal value applicable to the specified timezone.

Parameters
value:String

a string representing a floating temporal value

zoneId:ZoneId

a timezone applied to the parsed value

Returns:TemporalAdapter<ZonedDateTime>

an adapter containing the parsed temporal value

Exceptions
DateTimeParseException:
if the string cannot be parsed
parseback to summary
public static TemporalAdapter<ZonedDateTime> parse(String value, TzId tzId)

Parse a string representation of a temporal value applicable to the specified timezone.

Parameters
value:String

a string representing a floating temporal value

tzId:TzId

a timezone applied to the parsed value

Returns:TemporalAdapter<ZonedDateTime>

an adapter containing the parsed temporal value

Exceptions
DateTimeParseException:
if the string cannot be parsed
parseback to summary
public static TemporalAdapter<ZonedDateTime> parse(String value, TzId tzId, TimeZoneRegistry timeZoneRegistry)
Parameters
value:String

a string representing a floating temporal value

tzId:TzId

a timezone applied to the parsed value

timeZoneRegistry:TimeZoneRegistry

timezone definitions

toInstantStringback to summary
private String toInstantString(T temporal)

Return an ISO8601 instant string for the specified temporal value.

Parameters
temporal:T

a temporal value

Returns:String

a string

toLocalTimeback to summary
public ZonedDateTime toLocalTime()
toLocalTimeback to summary
public ZonedDateTime toLocalTime(ZoneId zoneId)
toLocalTimeback to summary
public static ZonedDateTime toLocalTime(Temporal temporal, ZoneId zoneId)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
toStringback to summary
public String toString(ZoneId zoneId)
toStringback to summary
private String toString(T temporal)
toStringback to summary
private String toString(T temporal, ZoneId zoneId)

Return a string representation of the given temporal value, using the specified zone ID for applicable values (i.e. values that support the DATE-TIME format).

Parameters
temporal:T

a temporal value

zoneId:ZoneId

the overriding zone id for DATE-TIME instances

Returns:String

a string

toStringback to summary
private String toString(CalendarDateFormat format, T temporal)
toStringback to summary
private String toString(CalendarDateFormat format, ZoneId zoneId, T temporal)