Here you can find the source of getCurrentTime(String pattern)
public static String getCurrentTime(String pattern)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getCurrentTime(String pattern) { if ("".equals(pattern) || null == pattern) { pattern = "yyyy-MM-dd HH:mm:ss"; }/* w w w .jav a 2 s. c o m*/ DateFormat df = new SimpleDateFormat(pattern); return df.format(new Date()); } public static String getCurrentTime() { DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return df.format(new Date()); } }