Java Date Format ISO formatISO8601(final Date date)

Here you can find the source of formatISO8601(final Date date)

Description

format ISO

License

Open Source License

Declaration

public static String formatISO8601(final Date date) 

Method Source Code


//package com.java2s;
/*/* w  w w . ja  v a2s .  co  m*/
 * ====================================================================
 * Copyright (c) 2005-2012 sventon project. All rights reserved.
 *
 * This software is licensed as described in the file LICENSE, which
 * you should have received as part of this distribution. The terms
 * are also available at http://www.sventon.org.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final String ISO8601_DATE_FORMAT_PATTERN = "yyyy-MM-dd";

    public static String formatISO8601(final Date date) {
        if (date == null)
            return "";
        SimpleDateFormat dateFormat = new SimpleDateFormat(ISO8601_DATE_FORMAT_PATTERN);
        return dateFormat.format(date);
    }
}

Related

  1. formatIso8601(Date date)
  2. formatIso8601(Date date)
  3. formatISO8601(Date date)
  4. formatIso8601(Date date)
  5. formatISO8601(Date date, TimeZone timeZone)
  6. formatISO8601(final Date date)
  7. formatISO8601Date(Date d)
  8. formatISO8601Date(Date date)
  9. formatISO8601Date(Date date)