TaskHelper { public static Date yesterdayZero(Date period) { Calendar cal = Calendar.getInstance(); cal.setTime(period); cal.add(Calendar.DAY_OF_YEAR, -1); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }  static String join(double[] array, char separator); static String join(double[] array, char separator, int startIndex, int endIndex); static String join(int[] array, char separator); static String join(int[] array, char separator, int startIndex, int endIndex); static String join(Number[] array, char separator); static String join(Number[] array, char separator, int startIndex, int endIndex); static Date nextMonthStart(Date period); static Date thisHour(Date period); static Date todayZero(Date period); static Date tomorrowZero(Date period); static Date yesterdayZero(Date period);  }
@Test public void testYesterdayZero() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_YEAR, 1); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date yesterdayZero = TaskHelper.yesterdayZero(cal.getTime()); Assert.assertEquals(cal.getTimeInMillis(), yesterdayZero.getTime() + 3600L * 1000 * 24); }
@Test public void testYesterdayZero2() { Assert.assertEquals(new Date(1562601600000L), TaskHelper.yesterdayZero(new Date(1562769422000L))); }