Here you can find the source of toISO8601(Date date)
Parameter | Description |
---|---|
date | The date to format |
public static String toISO8601(Date date)
//package com.java2s; /*// ww w . ja v a2 s. co m This file is part of Subsonic. Subsonic is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Subsonic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Subsonic. If not, see <http://www.gnu.org/licenses/>. Copyright 2009 (C) Sindre Mehus */ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final DateFormat ISO_8601_DATE_FORMAT = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss"); /** * Formats the given date to a ISO-8601 date/time format, and UTC timezone. * <p/> * The returned date uses the following format: 2007-12-17T14:57:17 * * @param date The date to format * @return The corresponding ISO-8601 formatted string. */ public static String toISO8601(Date date) { if (date == null) { return null; } synchronized (ISO_8601_DATE_FORMAT) { return ISO_8601_DATE_FORMAT.format(date); } } }