public static TimeZone calculateTimeZone(Object usertimeZone) { return calculateTimeZone(usertimeZone, TimeZone.getDefault()); }
protected String getValueWithTimeZone(FacesContext context, Clock clock) { Locale locale = context.getViewRoot().getLocale(); String value = ""; if (locale != null) { DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", locale); dateFormat.setTimeZone(CalendarUtils.calculateTimeZone(clock.getTimeZone())); value = dateFormat.format(new Date()); } return value; } }
protected void encodeEvents(FacesContext context, Schedule schedule) throws IOException { String clientId = schedule.getClientId(context); ScheduleModel model = schedule.getValue(); Map<String, String> params = context.getExternalContext().getRequestParameterMap(); if (model instanceof LazyScheduleModel) { String startDateParam = params.get(clientId + "_start"); String endDateParam = params.get(clientId + "_end"); Long startMillis = Long.valueOf(startDateParam); Long endMillis = Long.valueOf(endDateParam); TimeZone tz = CalendarUtils.calculateTimeZone(schedule.getTimeZone(), TimeZone.getTimeZone("UTC")); Date startDate = new Date(startMillis - tz.getOffset(startMillis)); Date endDate = new Date(endMillis - tz.getOffset(endMillis)); LazyScheduleModel lazyModel = ((LazyScheduleModel) model); lazyModel.clear(); //Clear old events lazyModel.loadEvents(startDate, endDate); //Lazy load events } encodeEventsAsJSON(context, schedule, model); }
List<Object> disabledDates = getDisabledDates(); if (disabledDates != null) { Calendar c = Calendar.getInstance(CalendarUtils.calculateTimeZone(getTimeZone()), calculateLocale(context)); c.setTime(date); int sYear = c.get(Calendar.YEAR); List<Object> disabledDays = getDisabledDays(); if (disabledDays != null) { Calendar c = Calendar.getInstance(CalendarUtils.calculateTimeZone(getTimeZone()), calculateLocale(context)); c.setTime(date); int dayOfWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM); String clientId = getClientId(context); TimeZone tz = CalendarUtils.calculateTimeZone(this.getTimeZone(), TimeZone.getTimeZone("UTC"));
public static final String getValue(FacesContext context, UICalendar calendar, Object value, String pattern) { //first ask the converter if (calendar.getConverter() != null) { return calendar.getConverter().getAsString(context, calendar, value); } else if (value instanceof String) { return (String) value; } //Use built-in converter else if (value instanceof Date) { SimpleDateFormat format = new SimpleDateFormat(pattern, calendar.calculateLocale(context)); format.setTimeZone(calculateTimeZone(calendar.getTimeZone())); return format.format((Date) value); } else { //Delegate to global defined converter (e.g. joda or java8) ValueExpression ve = calendar.getValueExpression("value"); if (ve != null) { Class type = ve.getType(context.getELContext()); if (type != null && type != Object.class && type != Date.class) { Converter converter = context.getApplication().createConverter(type); if (converter != null) { return converter.getAsString(context, calendar, value); } } } throw new FacesException("Value could be either String or java.util.Date"); } }
format.setTimeZone(CalendarUtils.calculateTimeZone(uicalendar.getTimeZone())); try { return format.parse(submittedValue);
protected void encodeEventsAsJSON(FacesContext context, Schedule schedule, ScheduleModel model) throws IOException { TimeZone timeZone = CalendarUtils.calculateTimeZone(schedule.getTimeZone(), TimeZone.getTimeZone("UTC"));
@Override public Converter getConverter() { Converter converter = super.getConverter(); if (converter == null && PrimeApplicationContext.getCurrentInstance(getFacesContext()).getConfig().isClientSideValidationEnabled()) { DateTimeConverter con = new DateTimeConverter(); con.setPattern(calculatePattern()); con.setTimeZone(CalendarUtils.calculateTimeZone(this.getTimeZone())); con.setLocale(calculateLocale(getFacesContext())); return con; } return converter; } }