Here you can find the source of getCurrentTime(String format)
public static String getCurrentTime(String format)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String FORMAT_DATE_TIME = "yyyy-MM-dd hh:mm"; private static SimpleDateFormat sdf = new SimpleDateFormat(); public static String getCurrentTime(String format) { if (format == null || format.trim().equals("")) { sdf.applyPattern(FORMAT_DATE_TIME); } else {/*from www .j a v a 2 s . c o m*/ sdf.applyPattern(format); } return sdf.format(new Date()); } }