Here you can find the source of formatDate(Date date)
Parameter | Description |
---|---|
date | The date object to format |
public static String formatDate(Date date)
//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); } }