Package org.primefaces.util
Class CalendarUtils
- java.lang.Object
-
- org.primefaces.util.CalendarUtils
-
public class CalendarUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TimeZonecalculateTimeZone(Object usertimeZone)static TimeZonecalculateTimeZone(Object usertimeZone, TimeZone defaultTimeZone)static ZoneIdcalculateZoneId(Object usertimeZone)static ZoneIdcalculateZoneId(Object usertimeZone, ZoneId defaultZoneId)static ZoneOffsetcalculateZoneOffset(Object usertimeZone)static ZoneOffsetcalculateZoneOffset(Object usertimeZone, ZoneId defaultZoneId)static LocalDateconvertDate2LocalDate(Date date)static LocalDateconvertDate2LocalDate(Date date, ZoneId zoneId)static LocalDateTimeconvertDate2LocalDateTime(Date date)static LocalDateTimeconvertDate2LocalDateTime(Date date, ZoneId zoneId)static LocalTimeconvertDate2LocalTime(Date date)static LocalTimeconvertDate2LocalTime(Date date, ZoneId zoneId)static DateconvertLocalDate2Date(LocalDate localDate, ZoneId zoneId)static DateconvertLocalDateTime2Date(LocalDateTime localDateTime)static DateconvertLocalDateTime2Date(LocalDateTime localDateTime, ZoneId zoneId)static DateconvertLocalTime2Date(LocalTime localTime, ZoneId zoneId)static StringconvertPattern(String pattern)Converts a java date pattern to a jquery UI date picker pattern.static voidencodeListValue(javax.faces.context.FacesContext context, UICalendar uicalendar, String optionName, List<?> values, String pattern)Write the value of Calendar optionsstatic LocalDategetObjectAsLocalDate(javax.faces.context.FacesContext context, UICalendar calendar, Object value)Try to convert the given value toLocalDateor returnnullif there is no appropriate converter for doing so.static LocalTimegetObjectAsLocalTime(javax.faces.context.FacesContext context, UICalendar calendar, Object value)Try to convert the given value toLocalTimeor returnnullif there is no appropriate converter for doing so.static StringgetTimeOnlyValueAsString(javax.faces.context.FacesContext context, UICalendar calendar)static StringgetValue(javax.faces.context.FacesContext context, UICalendar calendar, Object value, String pattern)static StringgetValueAsString(javax.faces.context.FacesContext context, UICalendar calendar)static StringgetValueAsString(javax.faces.context.FacesContext context, UICalendar calendar, Object value)static StringgetValueAsString(javax.faces.context.FacesContext context, UICalendar calendar, Object value, String pattern)static booleanhasTime(String pattern)static Temporalnow(UICalendar uicalendar)Calculates NOW based on the calendar's current timezone or will default to system timezone if none set.static Objectnow(UICalendar uicalendar, Class<?> dateType)Calculates NOW based on the calendar's current timezone or will default to system timezone if none set.static StringremoveTime(String pattern)static LocalDateTimetoLocalDateTime(ZoneId zoneId, String isoDateString)Convert ISO-String (@see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) to LocalDateTime.
-
-
-
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 toLocalDateor returnnullif there is no appropriate converter for doing so.- Parameters:
context- the faces contextcalendar- the calendar componentvalue- the value to convert- Returns:
- the
LocalDateobject ornull
-
getObjectAsLocalTime
public static LocalTime getObjectAsLocalTime(javax.faces.context.FacesContext context, UICalendar calendar, Object value)
Try to convert the given value toLocalTimeor returnnullif there is no appropriate converter for doing so.- Parameters:
context- the faces contextcalendar- the calendar componentvalue- the value to convert- Returns:
- the
LocalTimeobject ornull
-
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 IOExceptionWrite the value of Calendar options- Parameters:
context-uicalendar- componentoptionName- the name of an optionvalues- the List values of an optionpattern- the pattern for formatting- Throws:
IOException- if writer is null
-
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)
-
convertDate2LocalDateTime
public static LocalDateTime convertDate2LocalDateTime(Date date)
-
convertDate2LocalDateTime
public static LocalDateTime convertDate2LocalDateTime(Date date, ZoneId zoneId)
-
convertLocalDateTime2Date
public static Date convertLocalDateTime2Date(LocalDateTime localDateTime)
-
convertLocalDateTime2Date
public static Date convertLocalDateTime2Date(LocalDateTime localDateTime, ZoneId zoneId)
-
hasTime
public static final boolean hasTime(String pattern)
-
toLocalDateTime
public static LocalDateTime toLocalDateTime(ZoneId zoneId, String isoDateString)
Convert ISO-String (@see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) to LocalDateTime.- Parameters:
zoneId- Target-ZoneId of the LocalDateTime, the isoDateString is converted into.isoDateString-- Returns:
-
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
-
-