title: Jackson LocalDate: one day off during serialization
body: <p>I having issues when Jackson tries to serialize the LocalDate columns from my classes but the database is completely fine, everytime the JSON displays one day off from the database.</p>
  
  <p>While the database display as intended:</p>
  
  <p><code>2018-10-01</code></p>
  
  <p>The JSON output from calling a Spring REST entrypoint:</p>
  
  <p><code>{ "ticketStart": "2018-09-30" }</code></p>
  
  <p>It shows an day was lost. The database table doesn't store the time, just the date as intended, The timezones are completely discardable, since my project is for internal use. I tried to google my specific issue and the only i found <a href="https://stackoverflow.com/questions/31622254/lost-one-day-for-a-date">this</a> and <a href="https://stackoverflow.com/questions/44830861/spring-rest-localdate-utc-differs-of-one-day">this</a>, but none of them solved my problem.</p>
  
  <p>There's a way to enforce to serialize the dates from my database as-is, (aka: conversion disabled).</p>
  
  <p>Entity Code:</p>
  
  <pre><code>@Entity
  @Table(name="tickets")
  public class Ticket
  {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Getter
    @Setter
    private long TicketId;
  
    @Column(unique=true)
    @Getter
    @Setter
    private LocalDate TicketStart;
  
    @Column(unique=true)
    @Getter
    @Setter
    private LocalDate TicketEnd;
  
    //.... some fields omitted
  }
  </code></pre>
  
  <p>Since the Tickets entity are generated automatically by a CRON script or specified in a range of dates, where a ticket has the Monday and Sunday of every week:</p>
  
  <pre><code>public Ticket GenerateEmptyTicket(LocalDate begin, LocalDate end)
  {
      Ticket newTicket = new Ticket();
  
      newTicket.setTicketStart(begin);
      newTicket.setTicketEnd(end);
      newTicket.setYear(begin.getYear());
      newTicket.setMonth(begin.getMonth());
      newTicket.setLastMod(new Date());
  
      boolean isLocked = false;
      LocalDate date = LocalDate.now();
      if(date.isAfter(end)) isLocked = true;
  
      newTicket.setLocked(isLocked);
  
      //@TODO: Set a default responsible in the configuration.
      SystemUser rootUser = usersRepo.findByUsername("root").get();
      newTicket.setResponsable(rootUser);
  
      return newTicket;
  }
  
  public void GenerateTicketsBetweenTwoDates(LocalDate begin, LocalDate end)
  {        
      List&lt;LocalDate&gt; weekDates = new ArrayList&lt;&gt;();
  
      if(begin.getDayOfWeek() != DayOfWeek.MONDAY)
          while(begin.getDayOfWeek()  != DayOfWeek.MONDAY)
              begin = begin.minusDays(1);
  
  
      LocalDate tmp = begin;
      while(tmp.isBefore(end)){
          weekDates.add(tmp);
          tmp = tmp.plusWeeks(1);
      }
  
      if(end.getDayOfWeek() == DayOfWeek.MONDAY)
          weekDates.add(end);
  
  
      LocalDate current = LocalDate.now();
      List&lt;Ticket&gt; ticketsToSave = new ArrayList&lt;&gt;();
  
      for(LocalDate dat : weekDates)
      {
          logger.info("BEGIN DATE:" + dat.toString());
          LocalDate __end = dat.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
  
          if(current.isAfter(__end)) logger.info("LOCKED: YES");
  
          ticketsToSave.add(GenerateEmptyTicket(dat, __end));
      }
  
      ticketsRepo.saveAll(ticketsToSave);
  }    
  </code></pre>
  
  <p>The database and the Jackson serialization displays no errors, just the undesired "day off" result from Serialization.</p>
  
  <p>NOTE: The database JDBC connection (MySQL) specifies <code>useJDBCCompliantTimezoneShift=false&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC</code> from the application.properties <code>spring.datasource.url</code></p>