Here you can find the source of currentTime()
public static String currentTime()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** The time format string:(HH:mm:ss) */ public static final String TIME_FORMAT_STR = "HH:mm:ss"; /**//from ww w .ja v a 2s. c om * gets current time's string format like "HH:mm:ss" * * @return */ public static String currentTime() { return getTimeFormat(now()); } public static String getTimeFormat(java.util.Date date) { return getFormat(date, TIME_FORMAT_STR); } /** * Returns the current datetime. * * @return the current datetime. */ public static Date now() { return new Date(System.currentTimeMillis()); } public static String getFormat(java.util.Date date, String parseFormat) { if (null == date) { return null; } if (null == parseFormat || "".equalsIgnoreCase(parseFormat)) { return date.toString(); } return new SimpleDateFormat(parseFormat).format(date); } }