title: Spring Custom formatter not being called
body: <p>I am working on a rest api using spring framework. 
  All my attempts to get a custom formatter working with spring-boot have yielded no results. 
  The custom Annotation formatter should format a LocalDate, LocalDateTime and Dates. </p>
  
  <p>Even the pre-existing spring formatters ( @DateTimeFormat, @NumberFormat ) do not work.  </p>
  
  <p>This post <a href="https://stackoverflow.com/questions/19773500/spring-custom-validator-is-not-being-called">Spring: custom validator is not being called</a> is similar but I haven't noticed any mismatch in my code. </p>
  
  <p>The examples online regarding custom formatters use jsp's to get the value. Can they be used in a spring rest based projects rather than mvc ? Probably the way I am using the formatter is incorrect.</p>
  
  <p>Any help would greatly be appreciated. </p>
  
  <p>Thanks</p>
  
  <pre><code>public class BroadcastDateFormatter implements Formatter&lt;LocalDate&gt;
  {
  
  @Override
  public String print(LocalDate object, Locale locale)
  {
      // TODO Auto-generated method stub
      return null;
  }
  
  @Override
  public LocalDate parse(String text, Locale locale)
      throws ParseException
  {
      // TODO Auto-generated method stub
      return null;
  }
  
  } 
  
  
  public class BroadcastLocalDateFormatterAnnotationFactory implements     AnnotationFormatterFactory&lt;BroadcastLocalDateFormat&gt;
  {
  
  @Override
  public Set&lt;Class&lt;?&gt;&gt; getFieldTypes()
  {
      Set&lt;Class&lt;?&gt;&gt; classes = new HashSet&lt;&gt;();
      classes.add(LocalDate.class);
      classes.add(LocalDateTime.class);
      classes.add(Date.class);
      return classes;
  }
  
  @Override
  public Printer&lt;?&gt; getPrinter(BroadcastLocalDateFormat annotation, Class&lt;?&gt; fieldType)
  {
      return new BroadcastDateFormatter();
  }
  
  @Override
  public Parser&lt;?&gt; getParser(BroadcastLocalDateFormat annotation, Class&lt;?&gt; fieldType)
  {
      return new BroadcastDateFormatter();
  }
  
  }
  
  @Configuration
  @EnableWebMvc
  @EnableJpaRepositories(basePackages = { "com.test.*" })
  @EntityScan(basePackages = { "com.test.*" })
  @EnableAutoConfiguration(exclude = {    DataSourceTransactionManagerAutoConfiguration.class,   HibernateJpaAutoConfiguration.class })
  public class AppConfig
  extends WebMvcConfigurerAdapter
  {
  @Override
  public void addFormatters(FormatterRegistry registry)
  {
      registry.addConverter(new FilterExpressionConverter());
      registry.addFormatterForFieldAnnotation(new BroadcastLocalDateFormatterAnnotationFactory());
      registry.addFormatterForFieldAnnotation(new SSNAnnotationFormatterFactory());
      registry.addFormatter(new SSNFormatter());
      registry.addFormatter(new BroadcastDateFormatter());
  }
  
  
  public class FooDomain
  {
  @JsonProperty(value="my_current_date")
  @DateTimeFormat(pattern = "dd/MM/yyyy")
  @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-d")
  private LocalDate currentDate;
  
  @BroadcastLocalDateFormat
  private LocalDate broadcastDate;
  
  @NumberFormat(style=Style.CURRENCY, pattern = "#,###.###")
  private Double currency;
  }
  
  
  output: 
  {
        "string": "foo",
        "lng": 1,
        "integer": 1,
        "dbl": 1.2,
        "flt": 1.3,
        "bigDecimal": 1.1,
        "innerClass": {
          "string": "foo",
          "lng": 1,
          "integer": 1,
          "dbl": 1.2,
          "flt": 1.3,
          "bigDecimal": 1.1
        },
        "innerClassesList": [
          {
            "string": "foo",
            "lng": 1,
            "integer": 1,
            "dbl": 1.2,
            "flt": 1.3,
            "bigDecimal": 1.1
          },
          {
            "string": "foo",
            "lng": 1,
            "integer": 1,
            "dbl": 1.2,
            "flt": 1.3,
            "bigDecimal": 1.1
          }
        ],
        "innerClassSet": [
          {
            "string": "foo",
            "lng": 1,
            "integer": 1,
            "dbl": 1.2,
            "flt": 1.3,
            "bigDecimal": 1.1
          },
          {
            "string": "foo",
            "lng": 1,
            "integer": 1,
            "dbl": 1.2,
            "flt": 1.3,
            "bigDecimal": 1.1
          }
        ],
        "innerClassMap": {
          "1": {
            "string": "foo",
            "lng": 1,
            "integer": 1,
            "dbl": 1.2,
            "flt": 1.3,
            "bigDecimal": 1.1
          }
        },
        "someEnum": "FOO",
        "someObject": null,
        "bigDecimalPct": 1.1,
        "currency": 1001.3,
        "javUtilDate": "2017-01-16 20:20 PM UTC",
        "broadcastDate": [
          2017,
          1,
          16
        ],
        "broadcastDateTime": [
          2017,
          1,
          16,
          15,
          20,
          43,
          7000000
        ],
        "ssn": {
          "a": "a",
          "b": "b"
        },
        "my_current_date": "2017-01-16"
      }
  </code></pre>