@Test(expected = RuntimeException.class) public void test_should_throw_exception_when_input_date_is_not_of_expected_format() { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); final ESDateTimeFormatter esDateTimeFormatter = new ESDateTimeFormatter("UTC"); esDateTimeFormatter.toESDateTimeString("2017/12/03 23:45:23"); }
public String toESDateTimeString(String date) { if (isEmpty(date)) { return null; } try { final Date inputDate = INPUT_DATE_TIME_FORMAT.parse(date); return ES_DATE_TIME_FORMAT.format(inputDate); } catch (ParseException e) { throw new RuntimeException(e); } }
ESDateTimeFormatter { public String toESDateTimeString(String date) { if (isEmpty(date)) { return null; } try { final Date inputDate = INPUT_DATE_TIME_FORMAT.parse(date); return ES_DATE_TIME_FORMAT.format(inputDate); } catch (ParseException e) { throw new RuntimeException(e); } } }
ESDateTimeFormatter { public String toESDateTimeString(String date) { if (isEmpty(date)) { return null; } try { final Date inputDate = INPUT_DATE_TIME_FORMAT.parse(date); return ES_DATE_TIME_FORMAT.format(inputDate); } catch (ParseException e) { throw new RuntimeException(e); } } ESDateTimeFormatter(@Value("${app.timezone}") String timeZone); }
ESDateTimeFormatter { public String toESDateTimeString(String date) { if (isEmpty(date)) { return null; } try { final Date inputDate = INPUT_DATE_TIME_FORMAT.parse(date); return ES_DATE_TIME_FORMAT.format(inputDate); } catch (ParseException e) { throw new RuntimeException(e); } } ESDateTimeFormatter(@Value("${app.timezone}") String timeZone); String toESDateTimeString(String date); }
ESDateTimeFormatter { public String toESDateTimeString(String date) { if (isEmpty(date)) { return null; } try { final Date inputDate = INPUT_DATE_TIME_FORMAT.parse(date); return ES_DATE_TIME_FORMAT.format(inputDate); } catch (ParseException e) { throw new RuntimeException(e); } } ESDateTimeFormatter(@Value("${app.timezone}") String timeZone); String toESDateTimeString(String date);  }