Android examples for java.util:Date Format
get Date from long value and format in yyyy-MM-dd HH:mm:ss format
import java.text.SimpleDateFormat; import java.util.Calendar; public class Main{ public static final SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); public static String getDate(long time) { try {//w w w .ja va 2 s. co m Calendar c = Calendar.getInstance(); c.setTimeInMillis(time); return format.format(c.getTime()); } catch (Exception e) { e.printStackTrace(); } return ""; } }