Here you can find the source of formatDate(final Calendar cal)
public static String formatDate(final Calendar cal)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String formatDate(final Calendar cal) { if (cal == null) { throw new NullPointerException("cal"); }/*from w w w. j a va2 s.c o m*/ return formatDate(cal.getTime()); } public static String formatDate(final Date date) { if (date == null) { throw new NullPointerException("date"); } DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd"); return formatter.format(date); } }