Java Utililty Methods Time Now

List of utility methods to do Time Now

Description

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

Method

DategetNowTime()
get Now Time
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String dateStr = dateFormat(date);
try {
    date = format.parse(dateStr);
} catch (ParseException e) {
    e.printStackTrace();
return date;
StringgetNowTime()
yyyy-MM-dd HH:mm:ss
return allDateFmt.format(new Date());
StringgetNowTime(String format)
get Now Time
Date nowDate = new Date();
Calendar now = Calendar.getInstance();
now.setTime(nowDate);
SimpleDateFormat formatter = new SimpleDateFormat(format);
return formatter.format(now.getTime());
StringgetNowTime(String format, Locale loc)
get Now Time
if (format == null) {
    format = "yyyy-MM-dd HH:mm:ss";
if (loc == null)
    return new java.text.SimpleDateFormat(format).format(java.util.Calendar.getInstance().getTime());
return new java.text.SimpleDateFormat(format, loc).format(java.util.Calendar.getInstance().getTime());
StringgetNowTime(String formatStr)
get Now Time
return new SimpleDateFormat(formatStr).format(new Date());
StringgetNowWithLocal(boolean ifdatetime)
get current date by local pattern
java.util.Date dd = new java.util.Date();
if (ifdatetime) {
    return java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG, java.text.DateFormat.LONG)
            .format(dd);
} else {
    return java.text.DateFormat.getDateInstance(java.text.DateFormat.LONG).format(dd);
intgetNowYearMonth()
get Now Year Month
String returnStr = null;
SimpleDateFormat f = new SimpleDateFormat("yyyyMM");
Date date = new Date();
returnStr = f.format(date);
return Integer.parseInt(returnStr);
StringgetNowYMD()
get Now YMD
String str = now();
return str.substring(0, 10);
DategetSpecifiedDateTime_235959(Date curDate)
get Specified Date Tim_
return getSpecifiedDateTimeBySeconds(getFormatDateToDate(curDate), 24 * 60 * 60 - 1);
StringgetStrCurrentStrTime()
get Str Current Str Time
return getCurrentStrTime("yyyyMMddHHmmss");