Here you can find the source of formatDate(Date date, String patter)
Parameter | Description |
---|
public static String formatDate(Date date, String patter)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatDate(Date date, String patter) { try {//from ww w.java2s . com SimpleDateFormat sdf = new SimpleDateFormat(patter); return sdf.format(date); } catch (RuntimeException e) { return ""; } } public static String formatDate(Date date) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(date); } catch (RuntimeException e) { return ""; } } }