Class CalendarUtils


  • public class CalendarUtils
    extends Object
    • Method Detail

      • getValueAsString

        public static final String getValueAsString​(javax.faces.context.FacesContext context,
                                                    UICalendar calendar)
      • getObjectAsLocalDate

        public static LocalDate getObjectAsLocalDate​(javax.faces.context.FacesContext context,
                                                     UICalendar calendar,
                                                     Object value)
        Try to convert the given value to LocalDate or return null if there is no appropriate converter for doing so.
        Parameters:
        context - the faces context
        calendar - the calendar component
        value - the value to convert
        Returns:
        the LocalDate object or null
      • getObjectAsLocalTime

        public static LocalTime getObjectAsLocalTime​(javax.faces.context.FacesContext context,
                                                     UICalendar calendar,
                                                     Object value)
        Try to convert the given value to LocalTime or return null if there is no appropriate converter for doing so.
        Parameters:
        context - the faces context
        calendar - the calendar component
        value - the value to convert
        Returns:
        the LocalTime object or null
      • getValueAsString

        public static final String getValueAsString​(javax.faces.context.FacesContext context,
                                                    UICalendar calendar,
                                                    Object value)
      • getTimeOnlyValueAsString

        public static final String getTimeOnlyValueAsString​(javax.faces.context.FacesContext context,
                                                            UICalendar calendar)
      • getValueAsString

        public static final String getValueAsString​(javax.faces.context.FacesContext context,
                                                    UICalendar calendar,
                                                    Object value,
                                                    String pattern)
      • getValue

        public static final String getValue​(javax.faces.context.FacesContext context,
                                            UICalendar calendar,
                                            Object value,
                                            String pattern)
      • convertPattern

        public static final String convertPattern​(String pattern)
        Converts a java date pattern to a jquery UI date picker pattern.
        Parameters:
        pattern - Pattern to be converted
        Returns:
        converted pattern
      • encodeListValue

        public static void encodeListValue​(javax.faces.context.FacesContext context,
                                           UICalendar uicalendar,
                                           String optionName,
                                           List<?> values,
                                           String pattern)
                                    throws IOException
        Write the value of Calendar options
        Parameters:
        context -
        uicalendar - component
        optionName - the name of an option
        values - the List values of an option
        pattern - the pattern for formatting
        Throws:
        IOException - if writer is null
      • calculateZoneId

        public static ZoneId calculateZoneId​(Object usertimeZone)
      • calculateZoneId

        public static ZoneId calculateZoneId​(Object usertimeZone,
                                             ZoneId defaultZoneId)
      • calculateTimeZone

        public static TimeZone calculateTimeZone​(Object usertimeZone)
      • calculateTimeZone

        public static TimeZone calculateTimeZone​(Object usertimeZone,
                                                 TimeZone defaultTimeZone)
      • calculateZoneOffset

        public static ZoneOffset calculateZoneOffset​(Object usertimeZone)
      • calculateZoneOffset

        public static ZoneOffset calculateZoneOffset​(Object usertimeZone,
                                                     ZoneId defaultZoneId)
      • convertDate2LocalDate

        public static LocalDate convertDate2LocalDate​(Date date)
      • convertDate2LocalDate

        public static LocalDate convertDate2LocalDate​(Date date,
                                                      ZoneId zoneId)
      • convertDate2LocalDateTime

        public static LocalDateTime convertDate2LocalDateTime​(Date date)
      • convertDate2LocalTime

        public static LocalTime convertDate2LocalTime​(Date date)
      • convertDate2LocalTime

        public static LocalTime convertDate2LocalTime​(Date date,
                                                      ZoneId zoneId)
      • convertLocalDate2Date

        public static Date convertLocalDate2Date​(LocalDate localDate,
                                                 ZoneId zoneId)
      • convertLocalDateTime2Date

        public static Date convertLocalDateTime2Date​(LocalDateTime localDateTime)
      • convertLocalDateTime2Date

        public static Date convertLocalDateTime2Date​(LocalDateTime localDateTime,
                                                     ZoneId zoneId)
      • convertLocalTime2Date

        public static Date convertLocalTime2Date​(LocalTime localTime,
                                                 ZoneId zoneId)
      • removeTime

        public static final String removeTime​(String pattern)
      • hasTime

        public static final boolean hasTime​(String pattern)
      • now

        public static Temporal now​(UICalendar uicalendar)
        Calculates NOW based on the calendar's current timezone or will default to system timezone if none set. It will return a LocalDateTime if time units needed else just a LocalDate if no time is needed.
        Parameters:
        uicalendar - the base calendar to calculate NOW for
        Returns:
        a Temporal representing either a Date or DateTime
      • now

        public static Object now​(UICalendar uicalendar,
                                 Class<?> dateType)
        Calculates NOW based on the calendar's current timezone or will default to system timezone if none set.
        Parameters:
        uicalendar - the base calendar to calculate NOW for
        Returns:
        an Object representing either a Date or Temporal