@Test public void getDateFromStringUTC() throws ParseException { final Date expected = this.getDate("2023-06-21 05:03:50.456Z", "yyyy-MM-dd HH:mm:ss.SSS", TimeZone.getTimeZone("UTC")); final String dateText = "2023-06-21T05:03:50.456Z"; final Date actual = DateHelper.dateFromIsoString(dateText); assertThat(actual).isEqualTo(expected); }
public static Date dateFromIsoString(final String dateText) { final DateTimeFormatter dtf = DateTimeFormatter.ISO_DATE_TIME; final ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateText, dtf); return Date.from(zonedDateTime.toInstant()); }
DateHelper { public static Date dateFromIsoString(final String dateText) { final DateTimeFormatter dtf = DateTimeFormatter.ISO_DATE_TIME; final ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateText, dtf); return Date.from(zonedDateTime.toInstant()); } }
DateHelper { public static Date dateFromIsoString(final String dateText) { final DateTimeFormatter dtf = DateTimeFormatter.ISO_DATE_TIME; final ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateText, dtf); return Date.from(zonedDateTime.toInstant()); } private  DateHelper(); }
DateHelper { public static Date dateFromIsoString(final String dateText) { final DateTimeFormatter dtf = DateTimeFormatter.ISO_DATE_TIME; final ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateText, dtf); return Date.from(zonedDateTime.toInstant()); } private  DateHelper(); static Date getGmtDate(); static Date dateFromIsoString(final String dateText); }
DateHelper { public static Date dateFromIsoString(final String dateText) { final DateTimeFormatter dtf = DateTimeFormatter.ISO_DATE_TIME; final ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateText, dtf); return Date.from(zonedDateTime.toInstant()); } private  DateHelper(); static Date getGmtDate(); static Date dateFromIsoString(final String dateText);  }