Dec 272010

Issue: The date saved when using f:convertDateTime is off by one day, or off by some number of hours.

The issue is due to the default date/time converter in JSF using GMT instead of the system’s default time zone, so you can

1) specify the time zone directly in the converter, e.g.

<f:convertDateTime pattern="MM/dd/yyyy" timeZone="#{bean.timeZone}"/>


public TimeZone getTimeZone() {
     return TimeZone.getDefault();

in the bean (from, or you could

2) use a custom converter for the Date values, which looks like this:



public class CustomDateTimeConverter extends DateTimeConverter {

    /** Constructor. */
    public CustomDateTimeConverter() {

        // set the default timezone to the system time zone instead of GMT

With this second method you remove the <f:convertDateTime> from the date fields completely and the usage of <f:convertDateTime> overrides the specified default (if you don’t remove the convertDateTime tag then the specified default won’t be used and the problem will persist). From