Here you can find the source of nowISO8601()
public static String nowISO8601()
//package com.java2s; /*//from w w w.j av a 2 s . co m * Copyright (c) 2016-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /** * Get the current time formatted to ISO8601 * * @return date string */ public static String nowISO8601() { final TimeZone tz = TimeZone.getTimeZone("UTC"); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); df.setTimeZone(tz); return df.format(new Date()); } }