Java tutorial
//package com.java2s; import java.sql.Date; import java.text.SimpleDateFormat; import android.text.TextUtils; public class Main { public static String formateDateToString(Object longDate) { String time = null; if (longDate instanceof String) { time = (String) longDate; if (!TextUtils.isEmpty(time) && time.length() >= 16) { time = ((String) longDate).substring(0, 16); } } else if (longDate instanceof Long) { SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date date = new Date((Long) longDate); time = formatDate.format(date); } return time.trim(); } }