Here you can find the source of getTime(long time, boolean withMilliseconds)
public static String getTime(long time, boolean withMilliseconds) throws Exception
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getTime(long time, boolean withMilliseconds) throws Exception { SimpleDateFormat dateFormat = getDateFormat(withMilliseconds); return dateFormat.format(new Date(time)); }/*from w ww . j a v a2s .c o m*/ public static SimpleDateFormat getDateFormat(boolean withMilliseconds) throws Exception { if (withMilliseconds) { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); } return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } }