Java Date Format ISO formatIsoDate(Date date)

Here you can find the source of formatIsoDate(Date date)

Description

Formats a date to an ISO date representation.

License

Open Source License

Parameter

Parameter Description
date the date to convert

Return

the ISO date string

Declaration

public static String formatIsoDate(Date date) 

Method Source Code

//package com.java2s;
/*//w ww.j  av a 2s  .  c o m
 * RapidContext <http://www.rapidcontext.com/>
 * Copyright (c) 2007-2009 Per Cederberg & Dynabyte AB.
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the BSD license.
 *
 * This program 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 RapidContext LICENSE for more details.
 */

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

public class Main {
    /**
     * The ISO date format.
     */
    private static final SimpleDateFormat ISO_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");

    /**
     * Formats a date to an ISO date representation. Note that the
     * time component of the date value will be ignored.
     *
     * @param date           the date to convert
     *
     * @return the ISO date string
     */
    public static String formatIsoDate(Date date) {
        if (date == null) {
            return null;
        } else {
            return ISO_DATE_FORMAT.format(date);
        }
    }
}

Related

  1. formatISO8601Date(Date date)
  2. formatISO8601Date(final Calendar date)
  3. formatISO8601Date(final java.util.Date date)
  4. formatISO8601DateWOTime(final java.util.Date date)
  5. formatIso8601ForCCTray(Date date)
  6. formatISODate(Date date)
  7. formatISODateTime(Date date)
  8. formatOneDecimal(int iNumber, int iDivisor)
  9. formattedIso8601DateString(Calendar pCal)