DateUtils { public static String getDate(Long timeMills) { long duration = System.currentTimeMillis() - timeMills; return dateFormatter.format(new Date(timeMills)); }  static Long rfc3339ToMills(String dateInString); static String getDate(Long timeMills); static String getDate(int beforeDays);  }
@Test public void getDate_with_mils() { assertEquals("29 Oct 2019" , DateUtils.getDate(1572374198000L)); }
@Test public void getDate_with_prevDays() { final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); assertEquals(LocalDate.now().minusDays(4).format(formatter) , DateUtils.getDate(4)); assertEquals(LocalDate.now().format(formatter) , DateUtils.getDate(0)); assertEquals(LocalDate.now().format(formatter) , DateUtils.getDate(-1)); }