Class ICal4JDateCodec


  • @Technical
    @Bean
    @Singleton
    public class ICal4JDateCodec
    extends Object
    A decoder/encoder of iCal4J dates with Silverpeas dates.
    • Constructor Detail

      • ICal4JDateCodec

        public ICal4JDateCodec()
    • Method Detail

      • isEventDateToBeEncodedIntoUtc

        public boolean isEventDateToBeEncodedIntoUtc​(boolean eventRecurrent,
                                                     CalendarComponent component)
        Indicates if the date of an component must be encoded in UTC.
        Parameters:
        eventRecurrent - true if event is recurrent, false otherwise.
        component - the component data from which to verify the conditions.
        Returns:
        true if dates must be encoded into UTC, false otherwise.
      • encode

        public net.fortuna.ical4j.model.Date encode​(boolean eventRecurrent,
                                                    CalendarComponent component,
                                                    Temporal aTemporal)
        Encodes a temporal data into an iCal4J date.
        Parameters:
        eventRecurrent - true if event is recurrent, false otherwise.
        component - the component data to use to encode the given temporal.
        aTemporal - the temporal data to encode which have to be extracted from the given component.
        Returns:
        an iCal4J date.
        Throws:
        org.silverpeas.kernel.SilverpeasRuntimeException - if the encoding fails.
      • encode

        public net.fortuna.ical4j.model.Date encode​(Temporal aTemporal)
        Encodes a temporal data into an iCal4J date.
        Parameters:
        aTemporal - the temporal data to encode.
        Returns:
        an iCal4J date.
        Throws:
        IllegalArgumentException - if the encoding fails.
      • encode

        public net.fortuna.ical4j.model.DateList encode​(Collection<? extends Temporal> temporals)
        Encodes a temporal data set into an iCal4J date.
        Parameters:
        temporals - the temporal data set to encode.
        Returns:
        an iCal4J date.
        Throws:
        org.silverpeas.kernel.SilverpeasRuntimeException - if the encoding fails.
      • encode

        public net.fortuna.ical4j.model.DateTime encode​(OffsetDateTime dateTime)
        Encodes a datetime into an iCal4J date set in UTC.
        Parameters:
        dateTime - the datetime to encode.
        Returns:
        an iCal4J date.
        Throws:
        org.silverpeas.kernel.SilverpeasRuntimeException - if the encoding fails.
      • encode

        public net.fortuna.ical4j.model.DateTime encode​(ZonedDateTime dateTime)
        Encodes a datetime into an iCal4J date that takes into account the time zone of the specified datetime.
        Parameters:
        dateTime - the datetime with timezone to encode.
        Returns:
        an iCal4J date.
        Throws:
        org.silverpeas.kernel.SilverpeasRuntimeException - if the encoding fails.
      • encode

        public net.fortuna.ical4j.model.Date encode​(LocalDate date)
        Encodes a date into an iCal4J date.
        Parameters:
        date - a date.
        Returns:
        an iCal4J date.
        Throws:
        org.silverpeas.kernel.SilverpeasRuntimeException - if the encoding fails.
      • offsetDateTimeConversion

        public TemporalConverter.Conversion<OffsetDateTime,​net.fortuna.ical4j.model.Date> offsetDateTimeConversion()
        Gets the conversion function of an OffsetDateTime instance to an iCal4J date object. The function will throw a SilverpeasRuntimeException if the conversion fails.
        Returns:
        a conversion of a OffsetDateTime to an iCal4J DateTime value.
      • zonedDateTimeConversion

        public TemporalConverter.Conversion<ZonedDateTime,​net.fortuna.ical4j.model.Date> zonedDateTimeConversion()
        Gets the conversion function of a ZonedDateTime instance to an iCal4J date object. The function will throw a SilverpeasRuntimeException if the conversion fails.
        Returns:
        a conversion of a ZonedDateTime to an iCal4J DateTime value.
      • localDateConversion

        public TemporalConverter.Conversion<LocalDate,​net.fortuna.ical4j.model.Date> localDateConversion()
        Gets the conversion function of a LocalDate instance to an iCal4J date object. The function will throw a SilverpeasRuntimeException if the conversion fails.
        Returns:
        a conversion of a LocalDate to an iCal4J Date value.
      • getTimeZone

        public net.fortuna.ical4j.model.TimeZone getTimeZone​(ZoneId zoneId)
      • decode

        public final Temporal decode​(net.fortuna.ical4j.model.Date aDate)
        Decodes an iCal4J Date or DateTime into a Temporal.
        Parameters:
        aDate - the Date or DateTime to decode.
        Returns:
        a temporal instance. If the temporal contains time data, then UTC timezone is set.
        Throws:
        org.silverpeas.kernel.SilverpeasRuntimeException - if the decoding fails.