Here you can find the source of getCurrentTime()
public static String getCurrentTime()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String FORMAT1 = "yyyy-MM-dd HH:mm:ss"; public static final String FORMAT5 = "HH:mm:ss"; public static String getCurrentTime() { return getCurrentDateTime(FORMAT5); }/*from w w w . j a v a 2 s . c o m*/ public static String getCurrentDateTime() { return getCurrentDateTime(FORMAT1); } public static String getCurrentDateTime(String format) { SimpleDateFormat df = new SimpleDateFormat(format); return df.format(new Date()); } }