Here you can find the source of parseDate(Date date, String pattern)
public static String parseDate(Date date, String pattern)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static String dateFormat = "yyyy-MM-dd HH:mm:ss"; public static String parseDate(Date date, String pattern) { if (date == null) { return null; }// ww w .j a v a2 s.co m try { SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(date); } catch (Exception ex) { ex.printStackTrace(); return null; } } public static String parseDate(Date date) { if (date == null) { return null; } try { SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); return sdf.format(date); } catch (Exception ex) { ex.printStackTrace(); return null; } } }