Here you can find the source of dateToString(Date date, String formatStr)
Parameter | Description |
---|---|
date | date |
formatStr | formatStr |
public static String dateToString(Date date, String formatStr)
//package com.java2s; import java.text.*; import java.util.*; public class Main { /**//from w w w . j a v a 2s . co m * dateToString. * @param date date * @param formatStr formatStr * @return String */ public static String dateToString(Date date, String formatStr) { DateFormat format = new SimpleDateFormat(formatStr); return format.format(date); } /** * format. * @param input input * @param replace replace * @return String */ public static String format(String input, String... replace) { String str = ""; Formatter formatter = new Formatter(); try { str = formatter.format(input, (Object[]) replace).toString(); } finally { formatter.close(); } return str; } }