Here you can find the source of formatDateTime(final Calendar cal)
public static String formatDateTime(final Calendar cal)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String formatDateTime(final long date) { if (date < 0) { throw new IllegalArgumentException("date"); }/*from ww w .j av a 2 s . c om*/ Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(date); return formatDateTime(cal); } public static String formatDateTime(final Calendar cal) { if (cal == null) { throw new NullPointerException("cal"); } DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); return formatter.format(cal.getTime()); } }