DateTimeTools { public static String parseDateToString(String dateToParse) { try { return convertDateToString(parseStringToDate(dateToParse), getDateFormatString()); } catch (IllegalArgumentException ex) { LOG.debug("Failed to parse date '{}', error: {}", dateToParse, ex.getMessage(), ex); return StringUtils.EMPTY; } } private  DateTimeTools(); static String getDateFormatString(); static String getDateFormatLongString(); static SimpleDateFormat getDateFormat(); static SimpleDateFormat getDateFormatLong(); static String convertDateToString(Date convertDate); static String convertDateToString(DateTime convertDate); static String convertDateToString(Date convertDate, final String dateFormat); static String convertDateToString(DateTime convertDate, final String dateFormat); static String formatDuration(int duration); static int processRuntime(final String runtime); static String parseDateToString(String dateToParse); static Date parseStringToDate(final String dateToParse); static int extractYear(String date);  }
@Test public void testParseDateToString() { LOG.info("parseDateTo"); String dateToParse = "30 September 2010 (China)"; String expResult = "2010-09-30"; String result = DateTimeTools.parseDateToString(dateToParse); assertEquals(expResult, result); LOG.info("parseDateTo short"); dateToParse = "2010"; expResult = "2010-01-01"; result = DateTimeTools.parseDateToString(dateToParse); assertEquals(expResult, result); }