Here you can find the source of getTimeNow()
public static String getTimeNow()
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getTimeNow() { Calendar cal = Calendar.getInstance(); cal.getTime();/* w w w. ja v a 2s . c om*/ SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); return sdf.format(cal.getTime()); } }