title: Jackson objectMapper, trying to serialize LocalDate into "yyyy-MM-dd" and LocalTime into "HH:mm:ss"
body: <p>So I have an object like this</p>
  <pre><code>    @EqualsAndHashCode
  @Builder
  @NoArgsConstructor
  @Getter
  @Setter
  @AllArgsConstructor
  public class CreateBookingDto implements Serializable {
      @JsonFormat(pattern=&quot;yyyy-MM-dd&quot;)
      private LocalDate date;
      @JsonFormat(pattern=&quot;HH:mm:ss&quot;)
      private LocalTime startTime;
  }
  </code></pre>
  <p>I am trying to map it to a string and I get it a string like this</p>
  <pre><code>&quot;{
  &quot;date&quot;:
  {&quot;year&quot;:2021,&quot;month&quot;:&quot;JANUARY&quot;,&quot;dayOfWeek&quot;:&quot;SATURDAY&quot;,&quot;era&quot;:&quot;CE&quot;,&quot;chronology&quot;:{&quot;id&quot;:&quot;ISO&quot;,&quot;calendarType&quot;:&quot;iso8601&quot;},&quot;dayOfYear&quot;:16,&quot;leapYear&quot;:false,&quot;monthValue&quot;:1,&quot;dayOfMonth&quot;:16},
  &quot;startTime&quot;:
  {&quot;hour&quot;:16,&quot;minute&quot;:33,&quot;second&quot;:13,&quot;nano&quot;:721065000}}&quot;
  </code></pre>
  <p>How Can I map them to a string in the format &quot;yyyy-mm-dd&quot; for the date and &quot;HH:mm:ss&quot; for the time</p>
  <p>How I am mapping the object</p>
  <pre><code>def objectMapper = new ObjectMapper()
  def requestBodyJson = new ObjectMapper().writeValueAsString(dtoObject)
  </code></pre>
  <p>My pom</p>
  <pre><code>        &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-bom&lt;/artifactId&gt;
          &lt;version&gt;2.12.1&lt;/version&gt;
          &lt;type&gt;pom&lt;/type&gt;
      &lt;/dependency&gt;
  </code></pre>