Java Date Format ISO getISO8601Time()

Here you can find the source of getISO8601Time()

Description

Get current moment in ISO 8601 format http://stackoverflow.com/questions/3914404/how-to-get-current-moment-in-iso-8601-format 2016-01-20T10:53:52.457+08:00 2016-01-20T10:53:52.457+0800 2016-01-20T11:11:42.915Z

License

Apache License

Declaration

public static String getISO8601Time() 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    /**// w  w w . jav  a  2s. co  m
     * Get current moment in ISO 8601 format
     * http://stackoverflow.com/questions/3914404/how-to-get-current-moment-in-iso-8601-format
     * 2016-01-20T10:53:52.457+08:00
     * 2016-01-20T10:53:52.457+0800
     * 2016-01-20T11:11:42.915Z
     */
    public static String getISO8601Time() {
        // Choose one from the following two lines.
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
        // DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

        // Uncomment and modify the following line if you would like set the timezone explicitly.
        // df.setTimeZone(TimeZone.getTimeZone("Asia/Taipei"));
        return df.format(new Date());
    }
}

Related

  1. getIso8601DayDateFormat()
  2. getISO8601FormatDate(String in)
  3. getIso8601String(Date d)
  4. getISO8601String(Date date)
  5. getISO8601String(Date date)
  6. getISO8601Time(Date date)
  7. getISO8601UTCString(Date d)
  8. getISODate()
  9. getISODate()