if (date instanceof Date) {
return (Date) date;
} else {
if (date instanceof String) {
DateTimeConverter converter = new DateTimeConverter();
converter.setPattern(this.getDatePattern());
converter.setLocale(getAsLocale(this.getLocale()));
converter.setTimeZone(this.getTimeZone());
FacesContext context = FacesContext.getCurrentInstance();
return (Date) converter.getAsObject(context, this,
(String) date);
} else {
if (date instanceof Calendar) {
return ((Calendar) date).getTime();
} else {
FacesContext context = FacesContext.getCurrentInstance();
Converter converter = getConverter();
if(converter != null) {
return getAsDate(converter.getAsString(context, this, date));
}
Application application = context.getApplication();
converter = application.createConverter(date.getClass());
if (null != converter) {
return getAsDate(converter.getAsString(context, this, date));
} else {
throw new FacesException("Wrong attibute type or there is no converter for custom attibute type");
}
}