KunaUtils { public static Date toDate(String dateString) { try { return dateParserNoMillis().parse(dateString); } catch (ParseException e) { OffsetDateTime offsetDateTime = OffsetDateTime.parse(dateString); return new Date(offsetDateTime.toInstant().toEpochMilli()); } } private  KunaUtils(); static String toPairString(CurrencyPair currencyPair); static Date toDate(String dateString); static String format(Date date); static final String DATE_FORMAT_NO_MILLIS; }
@Test public void test_to_date() { String dateString = "2018-01-16T14:19:24+02:00"; Date actual = KunaUtils.toDate(dateString); assertThat(actual).isEqualToIgnoringHours(dateString); }