Format a date
String format(Date date)
- Formats a Date into a date/time string.
StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition fieldPosition)
- Overrides Format.
import java.text.DateFormat;
import java.util.Date;
public class Main{
public static void main(String args[]) {
DateFormat df = DateFormat.getDateInstance();
System.out.println(df.format(new Date()));
}
}
The output:
18-Nov-2010