Here you can find the source of getTimeDateStr(Date date)
public static final String getTimeDateStr(Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static final String getTimeDateStr(Date date) { if (date == null) { return null; }/* ww w .j a v a 2s . co m*/ Calendar cal = Calendar.getInstance(); cal.setTime(date); return getFixedTwoStr(cal.get(Calendar.HOUR_OF_DAY)) + ":" + getFixedTwoStr(cal.get(Calendar.MINUTE)) + " " + cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR); } public static String getFixedTwoStr(int i) { String fixedTwoStr = i + ""; if (i < 10) { fixedTwoStr = "0" + i; } return fixedTwoStr; } }