Here you can find the source of formatDateAndTime(long millis)
public static String formatDateAndTime(long millis)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String FORMAT_DATE_AND_TIME_YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm"; public static String formatDateAndTime(long millis) { if (millis == 0) return ""; SimpleDateFormat sdf = new SimpleDateFormat( FORMAT_DATE_AND_TIME_YYYY_MM_DD_HH_MM); Date dt = new Date(millis); String sDateTime = null;//www. j a v a 2 s . com sDateTime = sdf.format(dt); return sDateTime; } }