title: Why aren't milliseconds excluded from JSON when using dateFormat in Jackson's ObjectMapper with Java 8 dates?
body: <p>I am trying to figure out why Jackson (2.9.5) formats dates from Java 8 incorrectly.</p>
  <pre class="lang-kotlin prettyprint-override"><code>data class Test(
          val zonedDateTim: ZonedDateTime = ZonedDateTime.now(),
          val offsetDateTim: OffsetDateTime = OffsetDateTime.now(),
          val date: Date = Date(),
          val localDateTime: LocalDateTime = LocalDateTime.now()
  )
  
  val mapper = ObjectMapper().apply {
      registerModule(KotlinModule())
      registerModule(JavaTimeModule())
      dateFormat = SimpleDateFormat(&quot;yyyy-MM-dd'T'HH:mm:ss&quot;)
      enable(SerializationFeature.INDENT_OUTPUT)
  }
  
  println(mapper.writeValueAsString(Test()))
  </code></pre>
  <p>From the date format I provided I would expect to get dates formatted without milliseconds but instead the result looks like this:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;zonedDateTim&quot; : &quot;2018-07-27T13:18:26.452+02:00&quot;,
    &quot;offsetDateTim&quot; : &quot;2018-07-27T13:18:26.452+02:00&quot;,
    &quot;date&quot; : &quot;2018-07-27T13:18:26&quot;,
    &quot;localDateTime&quot; : &quot;2018-07-27T13:18:26.452&quot;
  }
  </code></pre>
  <p>Why are milliseconds being included in the formatted dates?</p>