Java Utililty Methods Date Now

List of utility methods to do Date Now

Description

The list of methods to do Date Now are organized into topic(s).

Method

StringgetCurrentTime(String format)
get Current Time
return timeToString(System.currentTimeMillis(), format);
StringgetCurrentTime(String format)
get Current Time
Calendar cal = new GregorianCalendar();
SimpleDateFormat date_format = new SimpleDateFormat(format);
return date_format.format(cal.getTime());
StringgetCurrentTime(String formatter)
get system time with a formatter
SimpleDateFormat fmt = new SimpleDateFormat(formatter);
fmt.setTimeZone(getTimeZone());
return fmt.format(new java.util.Date(System.currentTimeMillis()));
StringgetCurrentTime(String pattern)
get Current Time
return parseDate2String(new Date(), pattern);
StringgetCurrentTime(String pattern)
get Current Time
if ("".equals(pattern) || null == pattern) {
    pattern = "yyyy-MM-dd HH:mm:ss";
DateFormat df = new SimpleDateFormat(pattern);
return df.format(new Date());
StringgetCurrentTime(String pattern)
get Current Time
SimpleDateFormat format = getDateFormat(pattern);
return format.format(new Date());
StringgetCurrentTime(String pattern)
Get current time for pattern.
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
return dateFormat.format(new Date());
StringgetCurrentTime(String timeFormat)
get Current Time
if (timeFormat == null) {
    timeFormat = "MM/dd/yyy hh:mm:ss";
return new SimpleDateFormat(timeFormat).format(new Date());
StringgetCurrentTime2MysqlDateTime()
get Current Time Mysql Date Time
java.util.Date dt = new java.util.Date();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currentTime = sdf.format(dt);
return currentTime;
StringgetCurrentTimeAndDate()
Returns the current time and date in a formatted string.
return java.text.DateFormat.getDateTimeInstance().format(new java.util.Date());