DateUtils { public static Long rfc3339ToMills(String dateInString) { Calendar cal = Calendar.getInstance(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss.SSSSSS", Locale.getDefault()); try { cal.setTime(simpleDateFormat.parse(dateInString .replace("Z", "") .replace("T", "-") )); } catch (ParseException e) { e.printStackTrace(); } return cal.getTimeInMillis() + timelineOffset; }  static Long rfc3339ToMills(String dateInString); static String getDate(Long timeMills); static String getDate(int beforeDays);  }
@Test public void rfc3339ToMills() { assertEquals(1572374198000L , DateUtils.rfc3339ToMills("2019-10-29T18:36:38.000GMT").longValue()); long epoch = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); assertTrue(((epoch - DateUtils.rfc3339ToMills("abc").longValue()) < 1000)); epoch = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); assertTrue(((epoch - DateUtils.rfc3339ToMills("10-23-2001").longValue()) < 1000)); }