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

StringgetCurrentAccurateDateTimeStringForPrint()
get Current Accurate Date Time String For Print
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
return df.format(new Date());
intgetCurrentAgeByBirthdate(String brithday)
get Current Age By Birthdate
try {
    Calendar cal = Calendar.getInstance();
    int yearNow = cal.get(Calendar.YEAR);
    int monthNow = cal.get(Calendar.MONTH) + 1;
    int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
    cal.setTime(dateFormat.parse(brithday));
    int yearBirth = cal.get(Calendar.YEAR);
    int monthBirth = cal.get(Calendar.MONTH);
...
StringgetCurrentCacheTime()
get Current Cache Time
return getCacheValidatorTimeFormat().format(new Date());
CalendargetCurrentCalendar()
get Current Calendar
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String hehe = dateFormat.format(now);
System.out.println(hehe);
Calendar c = Calendar.getInstance();
return c;
StringgetCurrentCompactTime()
get Current Compact Time
Date NowDate = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
CurrentTime = formatter.format(NowDate);
return CurrentTime;
StringgetCurrentDataInFormat(String pattern)
get Current Data In Format
return getOffsetDateInFormat(0, pattern);
StringgetCurrentDataTimePrettyFilesystem()
get Current Data Time Pretty Filesystem
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss");
Calendar calendar = new GregorianCalendar();
return simpleDateFormat.format(calendar.getTime());
StringgetCurrentDate()
A method to get the current date to use in a timestamp
GregorianCalendar calendar = new GregorianCalendar();
DateFormat formatter = DateFormat.getDateInstance(DateFormat.FULL);
return formatter.format(calendar.getTime());
int[]getCurrentDate()
get Current Date
int[] dateBundle = new int[3];
String[] temp = getDataTime("yyyy-MM-dd").split("-");
for (int i = 0; i < 3; i++) {
    try {
        dateBundle[i] = Integer.parseInt(temp[i]);
    } catch (Exception e) {
        dateBundle[i] = 0;
return dateBundle;
DategetCurrentDate()
get Current Date
Date currentDate = new Date();
SimpleDateFormat df = new SimpleDateFormat(dateFormat);
df.format(currentDate);
currentDate.getTime();
return currentDate;