DateTimeExt { public static String toUtcDateTimeString(long msSinceEpoch) { if (msSinceEpoch == 0L) { return null; } return ISO_UTC_DATE_TIME_FORMATTER.format(Instant.ofEpochMilli(msSinceEpoch)) + 'Z'; } private  DateTimeExt(); static ZoneId toZoneId(String timeZoneName); static ZoneOffset toZoneOffset(String timeZoneName); static String toUtcDateTimeString(long msSinceEpoch); static String toLocalDateTimeString(long msSinceEpoch); static String toTimeUnitAbbreviation(TimeUnit timeUnit); static String toTimeUnitString(Duration duration); static String toTimeUnitString(long timeMs); static String toRateString(long interval, long itemsPerInterval, TimeUnit timeUnit, String rateType);  }
@Test public void testUtcDateTimeStringConversion() { ZonedDateTime now = ZonedDateTime.now(); String expected = DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(ZoneId.of("UTC")).format(now) + 'Z'; String actual = DateTimeExt.toUtcDateTimeString(Instant.from(now).toEpochMilli()); assertThat(actual).isEqualTo(expected); }