Here you can find the source of formatDateTime(final Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String formatDateTime(final Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); /**/*w w w . jav a 2s . co m*/ * Format the Date using pattern "yyyy-MM-dd HH:mm:ss" * * @param date * @return */ public static String formatDateTime(final Date date) { return formatDateTime(date, null); } public static String formatDateTime(final Date date, final String defaultValue) { if (date == null) { return defaultValue; } return dateTimeFormat.format(date); } }