I am new to Spring MVC and I just came across Spring Custom Formatters. So I am trying to create a Custom Formatter for java.util.Date. 

MyDateFormatter.java

```
public class MyDateFormatter implements Formatter<Date>{

  private String pattern = "yyyyMMdd";

   @Override
    public String print(Date date, Locale locale) {
        if (date == null) {
            return "";
        }
        return getDateFormat(locale).format(date);
    }

   @Override
    public Date parse(String formatted, Locale locale) throws ParseException {
        if (formatted.length() == 0) {
            return null;
        }
        return getDateFormat(locale).parse(formatted);
    }

    protected DateFormat getDateFormat(Locale locale) {
        DateFormat dateFormat = new SimpleDateFormat(this.pattern, locale);
        dateFormat.setLenient(false);
        return dateFormat;
    }
}

```

TestFormatterController.java

```
@Controller
public class TestFormatterController {
    @RequestMapping(value="/testFormatter")
    public String getDate(ModelMap map){
        Date date = new Date();
        map.put("date", date);
        return "testFormatter";
    }
}

```

testFormatter.jsp

```
<h1>${date}<h1>

```

Configuration

```
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
        <property name="formatters">
            <set>
                <bean class="mypackge.MyDateFormatter">
            </set>
        </property>
    </bean>

```

The output is not coming in yyyyMMdd. Could you please tell me what I am missing?