title: How to convert java.sql.Date to Days and Days to java.sql.Date in UTC using Java 8?
body: <p>I am trying to convert java.sql.Date to Days and convert the Days back to java.sql.Date all in UTC but I believe I am off by one day.</p>
  
  <p>I tried below my <code>millis1</code> and <code>millis2</code> are off by one day. </p>
  
  <pre><code>import java.sql.Date;
  import java.time.Instant;
  import java.time.temporal.ChronoUnit;
  import java.util.concurrent.TimeUnit;
  
  public class TestDate {
      public static void main(String... args) {
          String str="2015-03-31";
          Date date=Date.valueOf(str);
          long millis1 = date.getTime();
          System.out.println(millis1);
          int days = getDaysFromDate(date);
          long millis2 = getDateFromDays(days).getTime();
          System.out.println(millis2);
      }
  
      public static int getDaysFromDate(Date date) {
          return (int)ChronoUnit.DAYS.between(Instant.EPOCH, Instant.ofEpochMilli(date.getTime()));
      }
  
      public static Date getDateFromDays(int daysSinceEpoch) {
          return new Date(TimeUnit.DAYS.toMillis(daysSinceEpoch));
      }
  }
  </code></pre>