Here you can find the source of formatCalendar(Calendar calendar, String pattern)
public static String formatCalendar(Calendar calendar, String pattern)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String DEFAULTFORMAT = "yyyy-MM-dd HH:mm:ss"; public static String formatCalendar(Calendar calendar) { return formatCalendar(calendar, DEFAULTFORMAT); }//w w w . ja v a 2 s .co m public static String formatCalendar(Calendar calendar, String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); // sdf.setTimeZone(TimeZone.getTimeZone(timeZone)); return sdf.format(calendar.getTime()); } }