Here you can find the source of getSelectedDate(Calendar calendar, String pattern)
public static String getSelectedDate(Calendar calendar, String pattern)
//package com.java2s; import android.text.TextUtils; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static final String NORMAL_PATTERN = "yyyy-MM-dd HH:mm:ss"; public static String getSelectedDate(Calendar calendar, String pattern) { if (TextUtils.isEmpty(pattern)) { pattern = NORMAL_PATTERN;// ww w.j a v a2 s . co m } SimpleDateFormat formatter = new SimpleDateFormat(pattern); Date curDate = calendar.getTime(); String str = formatter.format(curDate); return str; } }