Java Date Format formatDate(Date date)

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

Description

Converts Date to String.

License

Open Source License

Parameter

Parameter Description
date <br> <div class="de"> date</div> <div class="fr"> date</div> <div class="it"> date</div>

Return

String - yyyyMMdd formatted

Declaration

public static String formatDate(Date date) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *
 * The authorship of this code and the accompanying materials is held by medshare GmbH, Switzerland.
 * All rights reserved. http://medshare.net
 *
 * Project Team: https://sourceforge.net/p/ehealthconnector/wiki/Team/
 *
 * This code is are made available under the terms of the Eclipse Public License v1.0.
 *
 * Accompanying materials are made available under the terms of the Creative Commons
 * Attribution-ShareAlike 4.0 License.//from   w w  w . ja va  2s .  com
 *
 * Year of publication: 2015
 *
 *******************************************************************************/

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

public class Main {
    /**
     * Converts Date to String.
     * 
     * @param date
     * <br>
     *          <div class="de"> date</div> <div class="fr"> date</div> <div
     *          class="it"> date</div>
     * @return String - yyyyMMdd formatted
     */
    public static String formatDate(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        return sdf.format(date);
    }

    /**
     * <div class="en">Format.</div> <div class="de"></div> <div class="fr"></div>
     * <div class="it"></div>
     * 
     * @param date
     * <br>
     *          <div class="de"> date</div> <div class="fr"> date</div> <div
     *          class="it"> date</div>
     * @return the string
     */
    public static String format(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        return sdf.format(date);
    }
}

Related

  1. formatDate(Date date)
  2. formatDate(Date date)
  3. formatDate(Date date)
  4. formatDate(Date date)
  5. formatDate(Date date)
  6. formatDate(Date date)
  7. formatDate(Date date, DateFormat dateFormat, char delimiter, boolean endWithDelimiter)
  8. formatDate(Date date, Locale locale)
  9. formatDate(Date date, SimpleDateFormat dateFormat)