LegacyConverters { public static LocalDate toLocalDate( Date date ) { Calendar c = Calendar.getInstance(); c.setTime( date ); int year = c.get( Calendar.YEAR ); int month = c.get( Calendar.MONTH ) + 1; int day = c.get( Calendar.DAY_OF_MONTH ); return LocalDate.of( year, month, day ); }  static ZonedDateTime toZonedDateTime( Date date ); static ZonedDateTime toZonedDateTime( Date date, ZoneId zoneId ); static LocalDateTime toLocalDateTime( Date date ); static LocalDate toLocalDate( Date date ); static LocalTime toLocalTime( Date date ); static YearMonth toYearMonth( Date date ); static MonthDay toMonthDay( Date date ); static Date toDate( ZonedDateTime dateTime ); static Date toDate( Instant instant ); static Timestamp toTimestamp( ZonedDateTime dateTime ); static Timestamp toTimestamp( Instant instant );  }
@Test public void dateToLocalDateTest() { long epochMillis = 31415926535L; Date date = new Date( epochMillis ); Calendar c = Calendar.getInstance(); c.setTime( date ); int year = c.get( Calendar.YEAR ); int month = c.get( Calendar.MONTH ) + 1; int day = c.get( Calendar.DAY_OF_MONTH ); LocalDate localDate = toLocalDate( date ); assertEquals( localDate.getYear(), year ); assertEquals( localDate.getMonthValue(), month ); assertEquals( localDate.getDayOfMonth(), day ); }