Android examples for java.util:Date Format
Format Date in long as yyyy-MM-dd HH:mm:ss format
import android.util.Log; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main{ /** The default formatter for get milliseconds*/ private static final DateFormat FULL_DATE_FORMATTER_MILLISECOND = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); public static String getFormateDateWithTime(long timestamp) { String dateString;/*from www. ja v a 2s . c om*/ Date date = new Date(timestamp); dateString = FULL_DATE_FORMATTER_MILLISECOND.format(date); return dateString; } }