/** * format the date as ISO * * @param d the date * * @return the formatted date */ private String formatDate(Date d) { if (sdf == null) { sdf = new SimpleDateFormat(DateUtil.DateFormatHandler .ISO_DATE_TIME.getDateTimeFormatString()); sdf.setTimeZone(DateUtil.TIMEZONE_GMT); } return sdf.format(d); }
/** * format time * * @param time time * * @return formatted time */ public static String getTimeAsISO8601(long time) { Calendar cal = Calendar.getInstance(TIMEZONE_GMT); cal.setTimeInMillis(time); Date curSysDate = cal.getTime(); return DateFormatHandler.ISO_DATE_TIME.getDateTimeStringFromDate( curSysDate); }
/** * parse the iso date * * @param s date string * * @return date * * @throws java.text.ParseException on badness */ private Date parseDate(String s) throws java.text.ParseException { if ((s == null) || (s.trim().length() == 0)) { return null; } if (sdf == null) { sdf = new SimpleDateFormat(DateUtil.DateFormatHandler .ISO_DATE_TIME.getDateTimeFormatString()); sdf.setTimeZone(DateUtil.TIMEZONE_GMT); } return sdf.parse(s); }