DynamoDBUtils { public static String getIso8601FromDate(Date date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(date); }  static String getIso8601FromDate(Date date); static List<String> getISODatesByRange(long epochBegin, long epochEnd);  }
@Test public void testGetIso8601FromDate() { long epoch = 1591706189000L; Date now = new Date(epoch); Date anHourAgo = new Date(epoch - TimeUnit.HOURS.toMillis(1)); Date yesterday = new Date(epoch - TimeUnit.DAYS.toMillis(1)); Date lastMonth = new Date(epoch - TimeUnit.DAYS.toMillis(30)); assertEquals("2020-06-09", DynamoDBUtils.getIso8601FromDate(now)); assertEquals("2020-06-09", DynamoDBUtils.getIso8601FromDate(anHourAgo)); assertEquals("2020-06-08", DynamoDBUtils.getIso8601FromDate(yesterday)); assertEquals("2020-05-10", DynamoDBUtils.getIso8601FromDate(lastMonth)); }