Java Utililty Methods Now

List of utility methods to do Now

Description

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

Method

Stringnow()
Returns current date/time as a string
return (DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date()));
Stringnow()
now
lock.lock();
try {
    return getDateFormat().format(new Date());
} finally {
    lock.unlock();
intnow()
now
return Integer.parseInt(new SimpleDateFormat("HHmmss").format(new Date()));
Stringnow()
now
String DATE_FORMAT = "dd.MM.yyyy HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
Date date = new Date();
return sdf.format(date);
Stringnow(String dateFormat)
now
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(cal.getTime());
Stringnow(String dateFormat)
Returns actual time and/or date in specified format.
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(cal.getTime());
Stringnow(String dateFormat)
Trasnforms String -->
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(cal.getTime());
Stringnow(String dateFormat)
now
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(cal.getTime());
Stringnow(String formatStr)
now
Date date = new Date();
DateFormat format = new SimpleDateFormat(formatStr);
return format.format(date);
Stringnow(String pattern)
now
DateFormat dateFormat = getFormat(pattern);
return dateFormat.format(new Date());