DateLibrary { public static String getTimeAsIso8601String(Date date) { return getTimeAsIso8601String(date, TimeZone.getDefault()); }  static String getTimeAsIso8601String(Date date); static String getTimeAsIso8601String(Date date, TimeZone timeZone); static Date getIso8601StringAsTime(String value); static Date getIso8601StringAsTime(String value, TimeZone timeZone); static Date getTimeAsDay(Date t); static Date getTimeAsDay(long t); static boolean hasAmPmClock(Locale locale);  }
@Test public void test() throws ParseException { DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); Date date = format.parse("2010-01-10 11:24:36 PST"); TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles"); String string = DateLibrary.getTimeAsIso8601String(date, tz); assertEquals("2010-01-10T11:24:36-08:00", string); }