Java中获取形如:20160811T122132+08
格式,可以通过如下方法
package com.mc.others; public class UTCTimeTest { @Test public void test1() { Calendar calendar = Calendar.getInstance(); DateFormat dtf = new SimpleDateFormat("yyyyMMdd'T'HHmmssZ"); Date now = calendar.getTime(); String format = dtf.format(now); System.out.println(format);//20160803T222649+0800 } @Test public void test2() { Date now = new Date(); DateFormat dtf = new SimpleDateFormat("yyyyMMdd'T'HHmmssZZ"); String format = dtf.format(now); System.out.println(format);//20160803T221641+0800 } @Test public void test3() { // org.joda.time.DateTime; DateTime dateTime = new DateTime(); String format = dateTime.toString(); System.out.println(format);//2016-08-03T22:14:19.293+08:00 } @Test public void test4() { DateTime dateTime = new DateTime(); String format = dateTime.toString("yyyyMMdd'T'HHmmssZZ");//20160803T221822+08:00 System.out.println(format); } }