Here you can find the source of format(final Date date, final String pattern)
public static String format(final Date date, final String pattern)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String format(final Date date) { return format(date, null); }/* www . j a va 2 s . c om*/ public static String format(final Date date, final String pattern) { if (date == null) { return null; } if (pattern != null) { return new SimpleDateFormat(pattern).format(date); } return new SimpleDateFormat("dd.MM.yyyy").format(date); } }