Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import android.content.Context; import android.text.format.DateUtils; public class Main { public static String formatDate(Context context, long date) { int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME; return DateUtils.formatDateTime(context, date, format_flags); } public static String formatDate(long date) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); return format.format(new Date(date)); } }