import org.joda.time.format.DateTimeFormatter;
import org.joda.time.DateTime;
private static final String UTC_FORMATTER_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
// 获取UTC时间
DateTimeFormatter fmt = DateTimeFormat.forPattern(UTC_FORMATTER_PATTERN);
DateTime now = DateTime.now(DateTimeZone.UTC);
String nowStr = fmt.print(now);
nowStr就是UTC时间格式。
如果要将UTC格式进行URL编码
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
String encodeTime = URLEncoder.encode(nowStr, StandardCharsets.UTF_8.name());