Here you can find the source of format(final Date date, final String format)
Parameter | Description |
---|---|
date | the date object |
format | the date format |
public static String format(final Date date, final String format)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /**/* ww w . j av a2 s .c o m*/ * Format a date object into a date String using a given date format. * * @param date * the date object * @param format * the date format * @return the formatted date */ public static String format(final Date date, final String format) { DateFormat dateFormat = new SimpleDateFormat(format, Locale.getDefault()); return dateFormat.format(date); } /** * Format a date object into a date String using the default date format. * * @param date * the date object * @return the formatted date */ public static String format(final Date date) { DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM); return dateFormat.format(date); } }