Here you can find the source of currentTime()
public static String currentTime()
//package com.java2s; import java.util.*; import java.text.SimpleDateFormat; public class Main { private static String TIME_FORMAT = "HH:mm:ss"; public static String currentTime() { return formatTime(Calendar.getInstance()); }//from www . j a v a2 s . c o m public static String formatTime(Calendar c) { if (c == null) return null; SimpleDateFormat df = new SimpleDateFormat(TIME_FORMAT); return df.format(c.getTime()); } public static String formatTime(Date d) { if (d == null) return null; SimpleDateFormat df = new SimpleDateFormat(TIME_FORMAT); return df.format(d); } }