public final class DateTimeUtilities
extends java.lang.Object
Temporal date and date-time types supported by iCalendar. DATE DATE_WITH_LOCAL_TIME DATE_WITH_LOCAL_TIME_AND_TIME_ZONE DATE_WITH_UTC_TIME: see iCalendar RFC 5545, page 32-33
includes methods to format a Temporal representing a DateTimeType as a String
Modifier and Type | Class and Description |
---|---|
static class |
DateTimeUtilities.DateTimeType |
Modifier and Type | Field and Description |
---|---|
static DateTimeUtilities.DateTimeType |
DEFAULT_DATE_TIME_TYPE
Default DateTimeType to use when none is specified.
|
static java.time.format.DateTimeFormatter |
LOCAL_DATE_TIME_FORMATTER |
static java.util.Comparator<java.time.temporal.Temporal> |
TEMPORAL_COMPARATOR
Compares two temporals of the same type
|
static java.time.format.DateTimeFormatter |
ZONED_DATE_TIME_FORMATTER |
static java.time.format.DateTimeFormatter |
ZONED_DATE_TIME_UTC_FORMATTER |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
dateTimePropertyTag(java.lang.String propertyName,
java.time.temporal.Temporal temporal)
Produces property name and attribute, if necessary.
|
static java.time.temporal.TemporalAmount |
durationBetween(java.time.temporal.Temporal startInclusive,
java.time.temporal.Temporal endExclusive)
Calculate TemporalAmount between two Temporals.
|
static java.lang.String |
format(java.time.temporal.Temporal temporal)
produced ISO.8601 date and date-time string for given Temporal of type
LocalDate, LocalDateTime or ZonedDateTime
|
static boolean |
isAfter(java.time.temporal.Temporal t1,
java.time.temporal.Temporal t2)
Determines if Temporal is after t2
Works for LocalDate or LocalDateTime
|
static boolean |
isBefore(java.time.temporal.Temporal t1,
java.time.temporal.Temporal t2)
Determines if Temporal is before t2
Works for LocalDate or LocalDateTime
|
static java.time.temporal.Temporal |
parse(java.lang.String temporalString)
Parse iCalendar date or date/time string into LocalDate, LocalDateTime or ZonedDateTime for following formats:
FORM #1: DATE WITH LOCAL TIME e.g.
|
static java.time.LocalDateTime |
toLocalDateTime(java.time.temporal.Temporal temporal)
Returns LocalDateTime from Temporal that is an instance of either LocalDate, LocalDateTime or ZonedDateTime
If the parameter is type LocalDate the returned LocalDateTime is atStartofDay.
|
static int |
weekOrdinalInMonth(java.time.temporal.Temporal dateBasedTemporal)
returns week of month.
|
public static final DateTimeUtilities.DateTimeType DEFAULT_DATE_TIME_TYPE
Default DateTimeType to use when none is specified. For example, when a date-only component is converted to a date-time one.
public static final java.time.format.DateTimeFormatter LOCAL_DATE_TIME_FORMATTER
public static final java.time.format.DateTimeFormatter ZONED_DATE_TIME_UTC_FORMATTER
public static final java.time.format.DateTimeFormatter ZONED_DATE_TIME_FORMATTER
public static final java.util.Comparator<java.time.temporal.Temporal> TEMPORAL_COMPARATOR
Compares two temporals of the same type
public static boolean isBefore(java.time.temporal.Temporal t1, java.time.temporal.Temporal t2)
Determines if Temporal is before t2 Works for LocalDate or LocalDateTime
t1
- first Temporalt2
- second Temporal (to compare with t1)public static boolean isAfter(java.time.temporal.Temporal t1, java.time.temporal.Temporal t2)
Determines if Temporal is after t2 Works for LocalDate or LocalDateTime
t1
- first Temporalt2
- second Temporal (to compare with t1)public static int weekOrdinalInMonth(java.time.temporal.Temporal dateBasedTemporal)
returns week of month. For example, a LocalDate representing March 10, 2016 returns 2, for the 2nd Thursday.
dateBasedTemporal
- - date based Temporal, such as LocalDatepublic static java.time.temporal.TemporalAmount durationBetween(java.time.temporal.Temporal startInclusive, java.time.temporal.Temporal endExclusive)
Calculate TemporalAmount between two Temporals. Both temporals must be the same type and representations of a DateTimeType.
startInclusive
- - the start temporal, not nullendExclusive
- - the end temporal, not nullpublic static java.time.temporal.Temporal parse(java.lang.String temporalString)
Parse iCalendar date or date/time string into LocalDate, LocalDateTime or ZonedDateTime for following formats: FORM #1: DATE WITH LOCAL TIME e.g. 19980118T230000 (LocalDateTime) FORM #2: DATE WITH UTC TIME e.g. 19980119T070000Z (ZonedDateTime) FORM #3: DATE WITH LOCAL TIME AND TIME ZONE REFERENCE e.g. TZID=America/New_York:19980119T020000 (ZonedDateTime) FORM #4: DATE ONLY e.g. VALUE=DATE:19970304 (LocalDate)
Note: strings can contain optionally contain "VALUE" "=" ("DATE-TIME" / "DATE")) before the date-time portion of the string. e.g. VALUE=DATE:19960401 VALUE=DATE-TIME:19980101T050000Z
Based on ISO.8601.2004
public static java.lang.String format(java.time.temporal.Temporal temporal)
produced ISO.8601 date and date-time string for given Temporal of type LocalDate, LocalDateTime or ZonedDateTime
temporal
- public static java.lang.String dateTimePropertyTag(java.lang.String propertyName, java.time.temporal.Temporal temporal)
Produces property name and attribute, if necessary. For example: LocalDate : DTSTART;VALUE=DATE: LocalDateTime : DTSTART: ZonedDateTime (UTC) : DTSTART: ZonedDateTime : DTEND;TZID=America/New_York:
propertyName
- temporal
- - temporal of LocalDate, LocalDateTime or ZonedDateTimepublic static java.time.LocalDateTime toLocalDateTime(java.time.temporal.Temporal temporal)
Returns LocalDateTime from Temporal that is an instance of either LocalDate, LocalDateTime or ZonedDateTime If the parameter is type LocalDate the returned LocalDateTime is atStartofDay. If the parameter is type ZonedDateTime the zoneID is changed to ZoneId.systemDefault() before taking the LocalDateTime.