Here you can find the source of getTodayString()
public static String getTodayString()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from w w w. j a v a 2 s.c om*/ * yyyy-MM-dd HH:mm:ss */ public static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static String getTodayString() { return format(new Date()); } public static String getTodayString(String dateFormat) { return format(new Date(), dateFormat); } public static String format(Date date) { return format(date, DATETIME_FORMAT); } public static String format(Date date, String dateFormat) { if (date != null) { SimpleDateFormat format = new SimpleDateFormat(dateFormat); String dateString = format.format(date); return dateString; } return null; } }