Here you can find the source of formatIso8601Date(Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String formatIso8601Date(Date date)
//package com.java2s; /**//from w ww . j a va 2 s . com * This file is part of the Squashtest platform. * Copyright (C) 2010 - 2016 Henix, henix.fr * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. * * This is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * this software 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this software. If not, see <http://www.gnu.org/licenses/>. */ import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String ISO_DATE = "yyyy-MM-dd"; /** * Formats a date into a an ISO 8601 string. <strong>The date will be formatted using the jvm default * timezone</strong> * * @param date * @return returns that date formatted according to the ISO 8601 Date (no time info) */ public static String formatIso8601Date(Date date) { if (date == null) { return null; } else { return formatDate(date, ISO_DATE); } } private static String formatDate(Date date, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }