Here you can find the source of formatDate(long millis)
public static String formatDate(long millis)
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import android.annotation.SuppressLint; public class Main{ private static final String FORMAT_DATE_YYYY_MM_DD = "yyyy-MM-dd"; private static final String FORMAT_DATE_YYYY_MM_DD2 = "yyyy/MM/dd"; @SuppressLint("SimpleDateFormat") /**?????Sting ??date*/ public static String formatDate(String date) { SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATE_YYYY_MM_DD); String newKey;// w w w . jav a2s .c om if (StringUtils.isEmpty(date) || date.equals("0")) { return ""; } else { newKey = date; } Date dt = new Date(Long.parseLong(newKey)); String sDateTime = null; sDateTime = sdf.format(dt); return sDateTime; } public static String formatDate(long millis) { if (millis == 0) return ""; SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATE_YYYY_MM_DD2); Date dt = new Date(millis); String sDateTime = null; sDateTime = sdf.format(dt); return sDateTime; } }