Here you can find the source of dateFormat(DateFormat f, Date d)
Parameter | Description |
---|---|
f | The DateFormat to use. |
d | The Date to be formatted. |
public static String dateFormat(DateFormat f, Date d)
//package com.java2s; //License from project: Open Source License import java.util.Date; import java.text.DateFormat; public class Main { /**//w ww .j a va 2 s.com * Formats a {@link Date} into a date/time string. The reason this method * is necessary is because date formats are not thread-safe. From the * {@link DateFormat} Javadoc: * <blockquote> * Date formats are not synchronized. It is recommended to create separate * format instances for each thread. If multiple threads access a format * concurrently, it must be synchronized externally. * </blockquote> * @param f The {@link DateFormat} to use. * @param d The {@link Date} to be formatted. * @return Returns the formatted string. */ public static String dateFormat(DateFormat f, Date d) { synchronized (f) { return f.format(d); } } }