Here you can find the source of format(Date date)
null
returns an empty String
Parameter | Description |
---|---|
date | the Date to format |
public static String format(Date date)
//package com.java2s; /******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * //w w w . j a v a 2 s . c om * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ import java.text.DateFormat; import java.util.Date; import java.util.Locale; public class Main { private static final DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.getDefault()); /** * Formats a Date based on the default Locale * If teh Date is <code>null</code> returns an empty String * * @param date the Date to format * @return the formatted Date as a String * @since 2.0 */ public static String format(Date date) { if (date == null) return ""; //$NON-NLS-1$ return dateFormat.format(date); } }