Monday, December 31, 2007

JSF DateTimeConverter Bug

A bug in the IBM WebSphere JSF implementation can cause the incorrect date to be displayed. The following serves as a workaround:
public class DateTimeConverter extends javax.faces.convert.DateTimeConverter {

/**
* Override the IBM DateTimeConverter getAsString implementation.
* Default the TimeZone.
* @param context - the FacesContext.
* @param component - the UIComponent to convert the value for.
* @param value - the value to be converted.
* @return String.
*/
public String getAsString(FacesContext context, UIComponent component, Object value) {
super.setTimeZone(TimeZone.getDefault());
return super.getAsString(context, component, value);
}

}

No comments: