/** * @see CalendarUtils#formatDate(java.util.Calendar) */ public static String getDate(long time) { Calendar cal=Calendar.getInstance(); cal.setTimeInMillis(time); return CalendarUtils.formatDate(cal); }
/** * @see CalendarUtils#parseDate(java.lang.String) */ public static java.sql.Date getDate(String yyyy_mm_dd) throws IllegalArgumentException { return new java.sql.Date(CalendarUtils.parseDate(yyyy_mm_dd).getTimeInMillis()); }
/** * Formats a date in YYYY-MM-DD format. * * @return the formatted date or <code>null</code> if the parameter is <code>null</code> */ public static String formatDate(Calendar cal) { if(cal == null) return null; try { StringBuilder result=new StringBuilder(10); // 10: Number of characters in "YYYY-MM-DD" formatDate(cal, result); return result.toString(); } catch(IOException e) { // Java 1.7: direct constructor AssertionError ae = new AssertionError("IOException should never occur on StringBuilder"); ae.initCause(e); throw ae; } }