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

StringgetNowDateTime(String strScheme)
get Now Date Time
String strReturn = null;
Date now = new Date();
try {
    SimpleDateFormat sdf = new SimpleDateFormat(strScheme);
    strReturn = sdf.format(now);
} catch (Exception e) {
    strReturn = "";
return strReturn;
StringgetNowDateTimeStrConcise()
get Now Date Time Str Concise
return getDateTimeStrConcise(new Date());
LonggetNowDayTimeLong()
get Now Day Time Long
String nowDay = sdFormatDay.format(new Date());
return sdFormatDay.parse(nowDay).getTime();
StringgetNowDefault()
get Now Default
return getNow("yyyyMMddHHmmss");
StringgetNowFileFormat()
Get current date/time - useful for filenames.
Calendar cal = Calendar.getInstance(TimeZone.getDefault());
String DATE_FORMAT = "yyyy-MM-dd-HHmmssSSS";
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
sdf.setTimeZone(TimeZone.getDefault());
return sdf.format(cal.getTime());
StringgetNowFormatLog()
get Now Format Log
String LOG_DATE_FORMAT = "yyyyMMdd HH:mm:ss";
java.util.Date dd = new java.util.Date();
java.text.SimpleDateFormat df = null;
String rtn = "";
df = new java.text.SimpleDateFormat(LOG_DATE_FORMAT);
rtn = df.format(dd);
return rtn;
StringgetNowFormattedDateTimeStr(String pattern)
get Now Formatted Date Time Str
return getFormattedDateTimeStr(pattern, new Date());
StringgetNowHour()
get Now Hour
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
return sdf.format(new Date());
StringgetNowInBanFormat()
get Now In Ban Format
return dateFormat.format(new Date());
StringgetNowInputDate()
get now day format : yyyyMMdd
return timeToString(DATE_FORMAT_INPUT_PAGE, new Date());