common-lang包:
String pattern = "YYYY-MM-dd'T'HH:mm:ssZZ"; System.out.println(DateFormatUtils.format(new Date(), pattern));
结果:
2012-04-13T10:53:43:119+08:00
转回来的时候使用:
DateTimeFormatter parser2 = ISODateTimeFormat.dateTimeNoMillis(); String jtdate = "2010-01-01T12:00:00+01:00"; System.out.println(parser2.parseDateTime(jtdate));