Here you can find the source of format(Calendar cal, String format)
public static String format(Calendar cal, String format)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String format(Date d, String format) { if (d == null) return ""; SimpleDateFormat myFormatter = new SimpleDateFormat(format); return myFormatter.format(d); }// w ww . ja v a 2 s .c om public static String format(Calendar cal, String format) { if (cal == null) return ""; SimpleDateFormat myFormatter = new SimpleDateFormat(format); return myFormatter.format(cal.getTime()); } }