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

StringcurrentDateStr(String format)
current Date Str
return toString(format, now());
StringcurrentDateString()
current Date String
Date now = new Date();
return (DEFAULT_DATE_FORMAT.format(now));
intcurrentDateTime(long time, int type)
current Date Time
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time);
return calendar.get(type);
StringcurrentDateTimeMillis()
current Date Time Millis
Calendar dt = Calendar.getInstance(TimeZone.getDefault());
String strYear = dt.get(Calendar.YEAR) + "";
int iTmp = dt.get(Calendar.MONTH) + 1;
String strMonth = iTmp + "";
String strDay = dt.get(Calendar.DAY_OF_MONTH) + "";
String hour = (dt.get(Calendar.HOUR_OF_DAY) < 10) ? "0" + dt.get(Calendar.HOUR_OF_DAY)
        : dt.get(Calendar.HOUR_OF_DAY) + "";
String minute = (dt.get(Calendar.MINUTE) < 10) ? "0" + dt.get(Calendar.MINUTE)
...
StringcurrentDateTimeToEasySortedDateTime()
Get the current date in an easy sorted format (e.g.
return toEasySortedDateTime(new Date(System.currentTimeMillis()));
StringcurrentGMTDateTime()
current GMT Date Time
TimeZone gmtTZ = TimeZone.getTimeZone("Europe/London");
Calendar gmtCalendar = GregorianCalendar.getInstance();
gmtCalendar.setTimeZone(gmtTZ);
Date date = gmtCalendar.getTime();
return date.toString();
longcurrentSystemDate()
current System Date
if (CurrentSystemDate - System.currentTimeMillis() > 120000) {
    Calendar calendar = Calendar.getInstance(GMT);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    CurrentSystemDate = calendar.getTimeInMillis();
return CurrentSystemDate;
StringcurrentXdsDate(int format)
current Xds Date
TimeZone tz = TimeZone.getTimeZone("GMT");
Calendar cal = new GregorianCalendar(tz);
return getXdsDate(cal, format);
StringgetCurrent()
get Current
SimpleDateFormat sdf = new SimpleDateFormat(commonDateFormat);
Date curDate = new Date();
String strDate = sdf.format(curDate);
return strDate;
DategetCurrent()
get Current
return getCurrent(DEFAULT_DATE_FORMAT);