Here you can find the source of getCurDateTime(String formatStr)
public static String getCurDateTime(String formatStr)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public final static String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss"; public static String getCurDateTime() { return getCurDateTime(DEFAULT_PATTERN); }/*from w ww .j a va 2s . c o m*/ public static String getCurDateTime(String formatStr) { SimpleDateFormat sdf = new SimpleDateFormat(formatStr); String now = sdf.format(new Date()); return now; } }