Class DateTimeUtilities

java.lang.Object
jfxtras.icalendarfx.utilities.DateTimeUtilities

public final class DateTimeUtilities extends Object
Temporal date and date-time types and supporting methods for 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
  • Field Details

    • DEFAULT_ZONE

      private static final ZoneId DEFAULT_ZONE
    • DEFAULT_DATE_TIME_TYPE

      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.
    • LOCAL_DATE_FORMATTER

      public static final DateTimeFormatter LOCAL_DATE_FORMATTER
    • LOCAL_TIME_FORMATTER

      static final DateTimeFormatter LOCAL_TIME_FORMATTER
    • LOCAL_DATE_TIME_FORMATTER

      public static final DateTimeFormatter LOCAL_DATE_TIME_FORMATTER
    • ZONED_DATE_TIME_UTC_FORMATTER

      public static final DateTimeFormatter ZONED_DATE_TIME_UTC_FORMATTER
    • ZONED_DATE_TIME_FORMATTER

      public static final DateTimeFormatter ZONED_DATE_TIME_FORMATTER
    • ZONE_FORMATTER

      static final DateTimeFormatter ZONE_FORMATTER
    • TEMPORAL_COMPARATOR

      public static final Comparator<Temporal> TEMPORAL_COMPARATOR
      Compares two temporals of the same type
    • TEMPORAL_COMPARATOR2

      public static final Comparator<Temporal> TEMPORAL_COMPARATOR2
      Compares two temporals of the LocalDate, LocalDateTime and ZonedDateTime Makes LocalDate at start of day. Add system default ZoneId to LocalDate and LocalDateTime
    • CONFLICT_CHECK_QUANTITY

      private static final int CONFLICT_CHECK_QUANTITY
      See Also:
  • Constructor Details

    • DateTimeUtilities

      private DateTimeUtilities()
  • Method Details

    • getTemporalComparator

      public static final Comparator<Temporal> getTemporalComparator(Temporal t)
      Returns correct comparator based on Temporal parameter
    • isBefore

      public static boolean isBefore(Temporal t1, Temporal t2)
      Determines if Temporal is before t2 Works for LocalDate, LocalDateTime and ZonedDateTime
      Parameters:
      t1 - first Temporal
      t2 - second Temporal (to compare with t1)
      Returns:
      true if t1 is before t2, false otherwise
    • isAfter

      public static boolean isAfter(Temporal t1, Temporal t2)
      Determines if Temporal is after t2 Works for LocalDate, LocalDateTime and ZonedDateTime
      Parameters:
      t1 - first Temporal
      t2 - second Temporal (to compare with t1)
      Returns:
      true if t1 is after t2, false otherwise
    • checkScheduleConflict

      public static String checkScheduleConflict(VEvent vEvent, List<VEvent> vEvents)
      Check if schedule conflict exists for
      invalid reference
      OPAQUE
      events using default check quantity
      Parameters:
      vEvent - event to test
      vEvents - existing events
      Returns:
      UID and start of recurrence of conflicting event, null otherwise
    • checkScheduleConflict

      public static String checkScheduleConflict(VEvent vEvent, List<VEvent> vEvents, int checkQuantity)
      Check if schedule conflict exists for
      invalid reference
      OPAQUE
      events.
      Parameters:
      vEvent - event to test
      vEvents - existing events
      checkQuantity - amount of recurrences to be tested
      Returns:
      UID and start of recurrence of conflicting event, null otherwise
    • weekOrdinalInMonth

      public static int weekOrdinalInMonth(Temporal dateBasedTemporal)
      returns week of month. For example, a LocalDate representing March 10, 2016 returns 2, for the 2nd Thursday.
      Parameters:
      dateBasedTemporal - - date based Temporal, such as LocalDate
      Returns:
      - ordinal week in month, such as 2nd (as in 2nd Wednesday in month)
    • temporalAmountBetween

      public static TemporalAmount temporalAmountBetween(Temporal startInclusive, Temporal endExclusive)
      Calculate TemporalAmount between two Temporals. Both temporals must be the same type and representations of a DateTimeType.
      Parameters:
      startInclusive - - the start temporal, not null
      endExclusive - - the end temporal, not null
      Returns:
      - Period for DATE, Duration for all other DateTimeTypes
    • temporalToString

      public static String temporalToString(Temporal temporal)
      produced ISO.8601 date and date-time string for given Temporal of type LocalDate, LocalDateTime or ZonedDateTime
      Parameters:
      temporal -
      Returns:
    • temporalFromString

      public static Temporal temporalFromString(String string)
      Parse ISO.8601 string into LocalDate, LocalDateTime or ZonedDateTime Temporal object.
    • dayOfWeekFromAbbreviation

      public static DayOfWeek dayOfWeekFromAbbreviation(String dayOfWeekAbbreviation)
      Convert 2-character string to DayOfWeek following below convention: weekday = "SU" / "MO" / "TU" / "WE" / "TH" / "FR" / "SA" Corresponding to SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY days of the week.
      Parameters:
      dayOfWeekAbbreviation - - 2 character abbreviation representing day of the week
      Returns:
      - associated DayOfWeek
    • toLocalDateTime

      @Deprecated public static LocalDateTime toLocalDateTime(Temporal temporal)
      Deprecated.
      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.