Here you can find the source of getTimeStamp(long timeMilis, boolean time, boolean date)
public static String getTimeStamp(long timeMilis, boolean time, boolean date)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { private static Calendar cal = Calendar.getInstance(); public static String getTimeStamp(long timeMilis, boolean time, boolean date) { return getTimeStamp(new StringBuilder(), timeMilis, time, date).toString(); }/*from w ww . ja va 2 s . com*/ public static StringBuilder getTimeStamp(StringBuilder sb, long timeMilis, boolean time, boolean date) { synchronized (cal) { cal.setTimeInMillis(timeMilis); int f; if (time) { f = cal.get(Calendar.HOUR_OF_DAY); if (f < 10) { sb.append("0"); } sb.append(f); sb.append(":"); f = cal.get(Calendar.MINUTE); if (f < 10) { sb.append("0"); } sb.append(f); sb.append(":"); f = cal.get(Calendar.SECOND); if (f < 10) { sb.append("0"); } sb.append(f); sb.append(" "); } if (date) { f = cal.get(Calendar.MONTH); if (f < 10) { sb.append("0"); } sb.append(f); sb.append("/"); f = cal.get(Calendar.DAY_OF_MONTH); if (f < 10) { sb.append("0"); } sb.append(f); sb.append("/"); sb.append(cal.get(Calendar.YEAR)); } return sb; } } }