Java Date Format formatDate(Date date)

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

Description

Formats a standard Java date into the MOCA date String (YYYYMMDDHHmmss) format.

License

Open Source License

Parameter

Parameter Description
date The date object to format

Return

The formatted string

Declaration

public static String formatDate(Date date) 

Method Source Code


//package com.java2s;
/*/*from ww  w  .j a  v  a  2s. c  o  m*/
 *  $URL$
 *  $Author$
 *  $Date$
 *  
 *  $Copyright-Start$
 *
 *  Copyright (c) 2010
 *  Sam Corporation
 *  All Rights Reserved
 *
 *  This software is furnished under a corporate license for use on a
 *  single computer system and can be copied (with inclusion of the
 *  above copyright) only for use on such a system.
 *
 *  The information in this document is subject to change without notice
 *  and should not be construed as a commitment by Sam Corporation.
 *
 *  Sam Corporation assumes no responsibility for the use of the
 *  software described in this document on equipment which has not been
 *  supplied or approved by Sam Corporation.
 *
 *  $Copyright-End$
 */

import java.text.DateFormat;

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

public class Main {
    private static final DateFormat _dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");

    /**
     * Formats a standard Java date into the MOCA date String (YYYYMMDDHHmmss) 
     * format.  If the date object provided is <code>null</code> then 
     * <code>null</code> is returned.
     * 
     * @param date The date object to format
     * @return The formatted string
     */
    public static String formatDate(Date date) {

        if (date == null)
            return null;

        DateFormat tmp = (DateFormat) _dateFormat.clone();
        return tmp.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)
  8. formatDate(Date date)
  9. formatDate(Date date)