Here you can find the source of getFormatedDate(Date date, String format)
Parameter | Description |
---|---|
date | date to be formatted |
format | format string specifying the required format of date |
public static String getFormatedDate(Date date, String format)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /**//from w ww . ja v a2 s. c o m * used to convert the specified date to the specified format * * @param date date to be formatted * @param format format string specifying the required format of date * @return returns string containing date in the specified format */ public static String getFormatedDate(Date date, String format) { DateFormat dateFormat = new SimpleDateFormat(format, Locale.getDefault()); return dateFormat.format(date); } }