Here you can find the source of formatDate(Date date, String format)
Parameter | Description |
---|---|
date | - the source date |
format | - the date format |
public static String formatDate(Date date, String format)
//package com.java2s; import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String DEFAULT_DATE_FORMAT = "yyyyMMddHHmmss"; public static String formatDate(Date date) { if (date == null) { return null; }//from w ww . ja v a 2 s .c o m Format formatter = new SimpleDateFormat(DEFAULT_DATE_FORMAT); return formatter.format(date); } /** * Format date by the format * @param date - the source date * @param format - the date format * * @return the result String */ public static String formatDate(Date date, String format) { if (date == null) { return null; } Format formatter = new SimpleDateFormat(format); return formatter.format(date); } }