List of usage examples for org.apache.commons.beanutils.converters DateConverter setTimeZone
public void setTimeZone(TimeZone timeZone)
From source file:airlift.util.AirliftUtil.java
/** * Creates the bean utils bean./*from www . j av a 2s. c om*/ * * @param _allowedDateTimePatterns the _allowed date time patterns * @param _timeZone the _time zone * @return BeansUtilsBean */ public static org.apache.commons.beanutils.BeanUtilsBean createBeanUtilsBean(String[] _allowedDateTimePatterns, java.util.TimeZone _timeZone) { org.apache.commons.beanutils.converters.SqlDateConverter sqlDateConverter = new org.apache.commons.beanutils.converters.SqlDateConverter(); sqlDateConverter.setPatterns(_allowedDateTimePatterns); sqlDateConverter.setTimeZone(_timeZone); org.apache.commons.beanutils.converters.DateConverter dateConverter = new org.apache.commons.beanutils.converters.DateConverter(); dateConverter.setPatterns(_allowedDateTimePatterns); dateConverter.setTimeZone(_timeZone); org.apache.commons.beanutils.converters.SqlTimestampConverter sqlTimestampConverter = new org.apache.commons.beanutils.converters.SqlTimestampConverter(); sqlTimestampConverter.setPatterns(_allowedDateTimePatterns); sqlTimestampConverter.setTimeZone(_timeZone); //registering "" (empty string) as a true value to support checkboxes with //the value attribute not being set. Setting the value //atrribute wil make the value visible on the form. This may //not be desired for a simple yes-no option hence the need to //register "" as true. String[] trueStrings = { "yes", "y", "true", "on", "1", "" }; String[] falseStrings = { "no", "n", "false", "off", "0" }; org.apache.commons.beanutils.converters.BooleanConverter booleanConverter = new org.apache.commons.beanutils.converters.BooleanConverter( trueStrings, falseStrings, Boolean.FALSE); org.apache.commons.beanutils.ConvertUtilsBean convertUtilsBean = new org.apache.commons.beanutils.ConvertUtilsBean(); convertUtilsBean.register(sqlDateConverter, java.sql.Date.class); convertUtilsBean.register(dateConverter, java.util.Date.class); convertUtilsBean.register(sqlTimestampConverter, java.sql.Timestamp.class); convertUtilsBean.register(booleanConverter, Boolean.class); convertUtilsBean.register(booleanConverter, Boolean.TYPE); return new org.apache.commons.beanutils.BeanUtilsBean(convertUtilsBean); }
From source file:org.bonitasoft.console.common.server.utils.ContractTypeConverter.java
public ContractTypeConverter(final String[] datePatterns) { convertUtilsBean = new ConvertUtilsBean(); convertUtilsBean.register(true, false, 0); final DateConverter dateConverter = new DateConverter(); dateConverter.setPatterns(datePatterns); dateConverter.setTimeZone(TimeZone.getTimeZone("GMT")); convertUtilsBean.register(dateConverter, Date.class); }