/** * Convert date to string. * * @param date date. * @return string. * @throws JSONException if the date is null. */ public static String toString(Date date) throws JSONException { checkNull(date); return DATE_FORMAT.get().format(date); }
/** * Convert string to date. * * @param date date. * @return string. * @throws JSONException if string has a wrong format or is null. */ public static Date toDate(String date) throws JSONException { checkNull(date); try { return DATE_FORMAT.get().parse(date); } catch (ParseException e) { throw new JSONException(e.getMessage()); } } }