@Test public void test_should_return_null_when_input_date_is_null() { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); final ESDateTimeFormatter esDateTimeFormatter = new ESDateTimeFormatter("UTC"); final String actualDateTimeString = esDateTimeFormatter.toESDateTimeString(null); assertNull(actualDateTimeString); }
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);  }