Package org.primefaces.util
Class CalendarUtils
java.lang.Object
org.primefaces.util.CalendarUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 LocalDateTimestatic 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 final 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 InstantgetObjectAsInstant(javax.faces.context.FacesContext context, UICalendar calendar, Object value, String attributeName) Try to convert the given value to anInstantor returnnullif there is no appropriate converter for doing so.static 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 final StringgetTimeOnlyValueAsString(javax.faces.context.FacesContext context, UICalendar calendar) static final StringgetValue(javax.faces.context.FacesContext context, UICalendar calendar, Object value, String pattern) static final StringgetValue(javax.faces.context.FacesContext context, UICalendar calendar, Object value, String pattern, boolean ignoreConverter) static final StringgetValueAsString(javax.faces.context.FacesContext context, UICalendar calendar) static final StringgetValueAsString(javax.faces.context.FacesContext context, UICalendar calendar, Object value) static final StringgetValueAsString(javax.faces.context.FacesContext context, UICalendar calendar, Object value, boolean ignoreConverter) static final StringgetValueAsString(javax.faces.context.FacesContext context, UICalendar calendar, Object value, String pattern) static final StringgetValueAsString(javax.faces.context.FacesContext context, UICalendar calendar, Object value, String pattern, boolean ignoreConverter) static final booleanstatic 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 final StringremoveTime(String pattern) splitRange(String dateRange, String pattern, String separator) 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 Details
-
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
-
getObjectAsInstant
public static Instant getObjectAsInstant(javax.faces.context.FacesContext context, UICalendar calendar, Object value, String attributeName) Try to convert the given value to anInstantor returnnullif there is no appropriate converter for doing so. The type of the value must be one ofLocalDateTime,LocalDate,LocalTime,Date(deprecated), or a parsable date or timeString. For any other this method throws aFacesException.- Parameters:
context- the faces contextcalendar- the calendar componentvalue- the value to convertattributeName- the attribute name of the value (e.g. mindate, or maxdate)- Returns:
- the
Instantobject ornull - Throws:
javax.faces.FacesException- if value type is not supported
-
getValueAsString
public static final String getValueAsString(javax.faces.context.FacesContext context, UICalendar calendar, Object value) -
getValueAsString
public static final String getValueAsString(javax.faces.context.FacesContext context, UICalendar calendar, Object value, boolean ignoreConverter) -
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) -
getValueAsString
public static final String getValueAsString(javax.faces.context.FacesContext context, UICalendar calendar, Object value, String pattern, boolean ignoreConverter) -
getValue
public static final String getValue(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, boolean ignoreConverter) -
convertPattern
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- componentoptionName- the name of an optionvalues- the List values of an optionpattern- the pattern for formatting- Throws:
IOException- if writer is null
-
calculateZoneId
-
calculateZoneId
-
calculateTimeZone
-
calculateTimeZone
-
calculateZoneOffset
-
calculateZoneOffset
-
convertDate2LocalDate
-
convertDate2LocalDate
-
convertDate2LocalDateTime
-
convertDate2LocalDateTime
-
convertDate2LocalTime
-
convertDate2LocalTime
-
convertLocalDate2Date
-
convertLocalDateTime2Date
-
convertLocalDateTime2Date
-
convertLocalTime2Date
-
removeTime
-
hasTime
-
toLocalDateTime
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
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
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
-
splitRange
-