Java Date Format As formatDateDashes(Date oDate)

Here you can find the source of formatDateDashes(Date oDate)

Description

Format a date with dashes.

License

EUPL

Parameter

Parameter Description
oDate a parameter

Declaration

public static String formatDateDashes(Date oDate) 

Method Source Code

//package com.java2s;
/*/* w  ww .  j  a v a2 s. c o m*/
 * Digital Assets Management
 * =========================
 * 
 * Copyright 2009 Fundaci?n Iavante
 * 
 * Authors: 
 *   Francisco Jos? Moreno Llorca <packo@assamita.net>
 *   Francisco Jes?s Gonz?lez Mata <chuspb@gmail.com>
 *   Juan Antonio Guzm?n Hidalgo <juan@guzmanhidalgo.com>
 *   Daniel de la Cuesta Navarrete <cues7a@gmail.com>
 *   Manuel Jos? Cobo Fern?ndez <ranrrias@gmail.com>
 *
 * Licensed under the EUPL, Version 1.1 or ? as soon they will be approved by
 * the European Commission - subsequent versions of the EUPL (the "Licence");
 * You may not use this work except in compliance with the Licence.
 * You may obtain a copy of the Licence at:
 *
 * http://ec.europa.eu/idabc/eupl
 *
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the Licence is distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Licence for the specific language governing permissions and 
 * limitations under the Licence.
 * 
 */

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**
     * Format a date with dashes.
     * 
     * @param oDate
     * @return
     */
    public static String formatDateDashes(Date oDate) {
        String sDate = "";

        if (oDate != null) {
            SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
            sDate = format.format(oDate);
        }

        return sDate;
    }
}

Related

  1. formatDateAsYYYYMMDD(Date date)
  2. formatDateBdChar(Date birthdate)
  3. formatDateByDefault(Date date)
  4. formatDateByYYYYMMDDHHmmss(Date date)
  5. formatDateCkan(Date date)
  6. formatDateDay(final Date date)
  7. formatDateForCompleteInfo(Date date)
  8. formatDateForGMT(Date moonDate)
  9. formatDateForLogFileName(Date date)