我需要在ISO 8601中获取SS毫秒和HH:MM时区的当前日期
完成日期加上小时,分钟,秒和小数秒:YYYY-MM-DDThh:mm:ss.sTZD(例如1997-07-16T19:20:30.45 + 01:00)
请参阅:http://www.w3.org/TR/NOTE-datetime
我尝试了不同的方法,但我无法得到正确的毫秒和时区数字:
DateFormat df=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSZZ");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
df.format(new Date());
Run Code Online (Sandbox Code Playgroud)
JAVA结果: 2012-11-24T21:19:27.758 + 0000
Apache结果: 2012-11-24T21:19:27.758 + 00:00(Apache Commons FastDateFormat)