Here you can find the source of getNowStr()
public static String getNowStr()
//package com.java2s; //License from project: Apache License import java.text.*; import java.util.*; public class Main { public static final String FORMAT_DATE_TIME = "yyyy-MM-dd HH:mm:ss"; /**/*from ww w. j a va 2 s. com*/ * get current date and time string * * @return a local datetime string */ public static String getNowStr() { return format(new Date(), FORMAT_DATE_TIME); } /** * get date string use pattern * * @param pattern * see {@link java.text.SimpleDateFormat} * @return a date string */ public static String format(String pattern) { return format(new Date(), pattern); } /** * get date string use pattern * * @param pattern * see {@link java.text.SimpleDateFormat} * @return a date string */ public static String format(Date date, String pattern) { SimpleDateFormat dateFormater = new SimpleDateFormat(pattern); return dateFormater.format(date); } }