Here you can find the source of formatDate(Date date)
public static String formatDate(Date date)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatDate(Date date) { return date != null ? createDateFormat().format(date) : null; }/*from w w w . j a v a 2 s . c o m*/ /** * Helper to create the date format used for parsing and writing Dates. */ private static DateFormat createDateFormat() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ"); /* (Not thread safe) */ } }