title: JSON parse error, unable to deserialize value of type `java.time.LocalDate` in STS 4.15.3 windows version
body: <p>I'm new to this tool and I'm having trouble with this specific issue. I looked for an example But could not find something similar, better, I found a possible solution, but in my case It doesn't work.</p>
  <p>I have this narrow project that resembles our famous CRUD, and I'm trying to reference the primary key from one table to another.</p>
  <ol>
  <li><p>Client Entity:</p>
  <pre><code>@Entity
  @Table(name = &quot;client&quot;)             
  public class Client {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @Column(name = &quot;cpf&quot;, length = 14)
      private String cpf;
  
      @Column(name = &quot;name&quot;, length = 100)
      private String name;
  
      @Column(name = &quot;birth_date&quot;)
      private LocalDate birthDate;
  
      @Column(name = &quot;address&quot;, length = 255)
      private String address;
  
      @Column(name = &quot;telephone&quot;, length = 14)
      private String telephone;
  
      @Column(name = &quot;email&quot;, length = 200)
      private String email;
  
      @Column(name = &quot;date_register&quot;, insertable = true, updatable = false)
      private LocalDate dateRegister;
  
      public Client() {
          super();
      }
  
      public Client(Long id, String cpf, String name, LocalDate birthDate, String address, String telephone, String email, LocalDate dateRegister) {
          super();
          this.id = id;
          this.cpf = cpf;
          this.name = name;
          this.birthDate = birthDate;
          this.address = address;
          this.telephone = telephone;
          this.email = email;
          this.dateRegister = dateRegister;
      }
  
      public Client(String cpf, String name, LocalDate birthDate, String address, String telephone, String email, LocalDate dateRegister) {
          super();
          this.cpf = cpf;
          this.name = name;
          this.birthDate = birthDate;
          this.address = address;
          this.telephone = telephone;
          this.email = email;
          this.dateRegister = dateRegister;
      }
  
      @PrePersist
      public void prePersist() {
          setDateRegister(LocalDate.now());
      }
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getCpf() {
          return cpf;
      }
  
      public void setCpf(String cpf) {
          this.cpf = cpf;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public LocalDate getBirthDate() {
          return birthDate;
      }
  
      public void setBirthDate(LocalDate birthDate) {
          this.birthDate = birthDate;
      }
  
      public String getAddress() {
          return address;
      }
  
      public void setAddress(String address) {
          this.address = address;
      }
  
      public String getTelephone() {
          return telephone;
      }
  
      public void setTelephone(String telephone) {
          this.telephone = telephone;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public LocalDate getDateRegister() {
          return dateRegister;
      }
  
      public void setDateRegister(LocalDate dateRegister) {
          this.dateRegister = dateRegister;
      }
  
      @Override
      public String toString() {
          return &quot;Client [id=&quot; + id + &quot;, cpf=&quot; + cpf + &quot;, name=&quot; + name + &quot;, birthDate=&quot; + birthDate + &quot;, address=&quot;
          + address + &quot;, telephone=&quot; + telephone + &quot;, email=&quot; + email + &quot;, dateRegister=&quot; + dateRegister + &quot;]&quot;;
      }
  }
  </code></pre>
  </li>
  <li><p>Sale Entity:</p>
  <pre><code>@Entity
  @Table(name = &quot;sale&quot;)
  public class Sale {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @ManyToOne
      @JoinColumn(name = &quot;client_id&quot;)
      private Client client;
  
      @OneToMany(mappedBy = &quot;sale&quot;)
      private List&lt;SaleItem&gt; items;
  
      @Column(name = &quot;payment_type&quot;, length = 10)
      @Enumerated(EnumType.STRING)
      private PaymentType paymentType;
  
      @Column(name = &quot;amount&quot;)
      private BigDecimal amount;
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public Client getClient() {
          return client;
      }
  
      public void setClient(Client client) {
          this.client = client;
      }
  
      public List&lt;SaleItem&gt; getItems() {
          return items;
      }
  
      public void setItems(List&lt;SaleItem&gt; items) {
          this.items = items;
      }
  
      public PaymentType getPaymentType() {
          return paymentType;
      }
  
      public void setPaymentType(PaymentType paymentType) {
          this.paymentType = paymentType;
      }
  
      public BigDecimal getAmount() {
          return amount;
      }
  
      public void setAmount(BigDecimal amount) {
          this.amount = amount;
      }
  
      @Override
      public String toString() {
          return &quot;Sale [id=&quot; + id + &quot;, client=&quot; + client + &quot;, items=&quot; + items + &quot;, paymentType=&quot; + paymentType
          + &quot;, amount=&quot; + amount + &quot;]&quot;;
      }   
  }
  </code></pre>
  </li>
  </ol>
  <p>The objective is to link the client to a sale through its primary key. These two codes refer to the sales repository and its controller:</p>
  <ol>
  <li><p>SaleRepository:</p>
  <pre><code>public interface SaleRepository extends JpaRepository&lt;Sale, Long&gt; {
  
  }
  </code></pre>
  </li>
  <li><p>SaleController:</p>
  <pre><code> @RestController
   @RequestMapping(&quot;/api/sales&quot;)
   @CrossOrigin(&quot;*&quot;)
   public class SaleController {
  
       @Autowired
       private SaleRepository repository;
  
       @Autowired
       private SaleItemRepository saleItemrepository;
  
       @PostMapping
       @Transactional
       public void save(@RequestBody Sale sale) {
           repository.save(sale);
           sale.getItems().stream().forEach(saleItem -&gt; saleItem.setSale(sale));
           saleItemrepository.saveAll(sale.getItems());
       }
  
  }
  </code></pre>
  </li>
  </ol>
  <p>And the problem is exactly how this reference is being made. In the current <code>private Client client;</code> way , the client object is being passed in full instead of its id, that's why it throws this following error when I try to register the sale.</p>
  <pre><code>Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.time.LocalDate` from String &quot;31/05/1968&quot;: Failed to deserialize java.time.LocalDate: (java.time.format.DateTimeParseException) Text '31/05/1968' could not be parsed at index 0; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.LocalDate` from String &quot;31/05/1968&quot;: Failed to deserialize java.time.LocalDate: (java.time.format.DateTimeParseException) Text '31/05/1968' could not be parsed at index 0&lt;EOL&gt; at [Source: (PushbackInputStream); line: 1, column: 87] (through reference chain: MyNameIsRafaelSampaio.github.com.bruxo_vendas_ltda_api.model.Sale[&quot;client&quot;]-&gt;MyNameIsRafaelSampaio.github.com.bruxo_vendas_ltda_api.model.Client[&quot;birthDate&quot;])]
  </code></pre>
  <p>As was to be expected, since the column <code>birthDate</code>  present in the client entity is not being treated correctly in the sale entity. I did research on a possible solution but none made much sense to me, I believe for being a newbie, one of the solutions that I found more understandable was the use of the <code>@MapsId</code>  tag. I tried to make changes to adapt, but I was not successful, if you can help I will be grateful.</p>