Java tutorial
//package com.java2s; import android.text.TextUtils; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getFormatTime(String format, long time) { if (TextUtils.isEmpty(format)) return null; SimpleDateFormat dateFormat = new SimpleDateFormat(format); Date date = new Date(time); return dateFormat.format(date); } public static String getFormatTime(String format, String time) { if (TextUtils.isEmpty(format) || TextUtils.isEmpty(time)) return null; return getFormatTime(format, Long.valueOf(time)); } }