Here you can find the source of getCurrDate()
@SuppressWarnings("finally") public static Date getCurrDate()
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { @SuppressWarnings("finally") public static Date getCurrDate() { DateFormat formatter = new SimpleDateFormat("yyyyMMddhhmmssSSS"); long now = System.currentTimeMillis(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(now);/* ww w . j av a 2s . co m*/ return calendar.getTime(); } public static String getTime() { java.util.Date dt = new java.util.Date(); java.sql.Timestamp ts = new java.sql.Timestamp(dt.getTime()); String time = ts.toString(); return time.substring(0, 19); } }