Here you can find the source of format(String str)
public static String format(String str)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static String format(String str) { return String.format("%tF", parse(str, "EEE MMM dd HH:mm:ss zzz yyyy", Locale.US)); }/* w w w.j a v a 2 s . c om*/ public static String format(Date date, String pattern, Locale locale) { if (date == null || pattern == null) { return null; } return new SimpleDateFormat(pattern, locale).format(date); } public static Date parse(String str, String pattern, Locale locale) { if (str == null || pattern == null) { return null; } try { return new SimpleDateFormat(pattern, locale).parse(str); } catch (ParseException e) { e.printStackTrace(); } return null; } }