Here you can find the source of getStrDateForLong(long time)
public static String getStrDateForLong(long time)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { /**yyyy-MM-dd HH:mm:ss*/ private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static String getStrDateForLong(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time);//w ww .j a va2s .c om return getDefaultFormatByDate(calendar.getTime()); } public static String getDefaultFormatByDate(Date date) { return dateFormat.format(date); } }