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()
get Current Time
java.util.Calendar cal = java.util.Calendar.getInstance();
return new java.text.SimpleDateFormat(TIME_FORMAT).format(cal.getTime());
StringgetCurrentTime()
get Current Time
Calendar calendar = Calendar.getInstance(Locale.CHINESE);
calendar.setTimeInMillis(new Date().getTime());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
return dateFormat.format(calendar.getTime());
StringgetCurrentTime()
This method is used to current time
Date currentTimeStamp = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
return dateFormat.format(currentTimeStamp);
StringgetCurrentTime()
get Current Time
return getCurrentDateTime(FORMAT5);
StringgetCurrentTime()
get Current Time
SimpleDateFormat fmt = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", Locale.US);
fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
return fmt.format(new Date());
StringgetCurrentTime(Date _d)
get Current Time
SimpleDateFormat formatter = new SimpleDateFormat("HHmmss");
return formatter.format(_d);
DategetCurrentTime(long delay, long interval)
get Current Time
long current = System.currentTimeMillis();
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
long date = 0;
try {
    date = sf.parse(sf.format(new Date())).getTime();
    current = System.currentTimeMillis() - date - delay;
} catch (ParseException e) {
return new Date(date + delay + (current / interval) * interval);
StringgetCurrentTime(String format)
get Current Time
int millisPerHour = 60 * 60 * 1000;
SimpleDateFormat fmt = new SimpleDateFormat(format);
SimpleTimeZone timeZone = new SimpleTimeZone(9 * millisPerHour, "KST");
fmt.setTimeZone(timeZone);
String str = fmt.format(new java.util.Date(System.currentTimeMillis()));
return str;
StringgetCurrentTime(String format)
get Current Time
if (format == null || format.trim().equals("")) {
    sdf.applyPattern(FORMAT_DATE_TIME);
} else {
    sdf.applyPattern(format);
return sdf.format(new Date());
StringgetCurrentTime(String format)
get Current Time
long time = System.currentTimeMillis();
SimpleDateFormat dayTime = new SimpleDateFormat(format);
String currentTime = dayTime.format(new Date(time));
return currentTime;