Here you can find the source of format(Calendar calendar)
public static String format(Calendar calendar)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); public static String format(Calendar calendar) { if (calendar == null) { return null; }//from w w w . j a v a2 s .c om return DATE_FORMAT.format(calendar.getTime()); } }