Here you can find the source of formatShortTime()
public static String formatShortTime()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static final SimpleDateFormat HH_mm = new SimpleDateFormat("HH:mm"); public static String formatShortTime() { return HH_mm.format(getCalendar().getTime()); }//from www. j a va 2 s. c o m public static String formatShortTime(long millis) { return HH_mm.format(new Date(millis)); } public static String formatShortTime(Calendar cal) { return HH_mm.format(cal.getTime()); } public static String formatShortTime(Date date) { return HH_mm.format(date); } public static Calendar getCalendar() { return Calendar.getInstance(); } public static Calendar getCalendar(long millis) { Calendar cal = Calendar.getInstance(); cal.setTime(new Date(millis)); return cal; } }