@Test public void test_should_convert_date_to_elastic_search_string_format_with_utc_timezone() { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); final ESDateTimeFormatter esDateTimeFormatter = new ESDateTimeFormatter("UTC"); final String actualDateTimeString = esDateTimeFormatter.toESDateTimeString("03-12-2017 23:45:23"); assertEquals("2017-12-03T23:45:23.000+0000", 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);  }