Here you can find the source of date()
public static String date()
//package com.java2s; //License from project: Open Source License import java.util.Date; import java.util.Calendar; public class Main { final static String DATE_FORMAT = "%tH:%<tM:%<tS.%<tL"; private static int timeOffset = 0; public static String date() { return String.format(DATE_FORMAT, getDate()); }/*from ww w . j ava2 s .c om*/ private static Date getDate() { Calendar cal = Calendar.getInstance(); cal.add(Calendar.MILLISECOND, timeOffset); return cal.getTime(); } }