Java tutorial
//package com.java2s; import android.text.format.DateFormat; import java.util.Calendar; public class Main { public static String getFormattedDate(Calendar calendar, String pFormat) { return DateFormat.format(pFormat, calendar).toString(); } public static String getFormattedDate(long pEpochMillis, String pFormat) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(pEpochMillis); return DateFormat.format(pFormat, calendar).toString(); } }