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

ListgetCurrentMonthday()
get Current Monthday
List<String> currentmonth = new ArrayList<String>();
Calendar c = Calendar.getInstance();
int totalday = c.getActualMaximum(Calendar.DAY_OF_MONTH);
System.out.println("current month total day is :" + totalday);
c.set(Calendar.DAY_OF_MONTH, 1);
System.out.println("first day is :" + new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()));
for (int index = 1; index <= totalday; index++) {
    c.set(Calendar.DAY_OF_MONTH, index);
...
StringgetCurrentMonthLastDay()
get Current Month Last Day
String current = getCurrentStringDate();
int year = Integer.parseInt(current.substring(0, 4));
int month = Integer.parseInt(current.substring(5, 7));
int day = getMonthDaysByYearMonth(year, month);
return current.substring(0, 7) + "-" + day;
StringgetCurrentMonthStartTime()
get Current Month Start Time
Calendar c = Calendar.getInstance(Locale.CHINA);
String now = null;
c.setTime(new Date());
c.set(Calendar.MONTH, c.get(Calendar.MONTH));
c.set(Calendar.DAY_OF_MONTH, +1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
...
StringgetCurrentMonthString(Calendar calendar)
get the current month
int currentMonth = calendar.get(Calendar.MONTH);
String[] monthArr = new DateFormatSymbols().getMonths();
String month = monthArr[currentMonth];
return calendar.get(Calendar.YEAR) + "-" + month;
StringgetCurrentODSDate()
get Current ODS Date
return asODSDate(new Date());
StringgetCurrentPlainDate()
Get current date as string in format yyyymmdd
return getPlainDateFrom(new Date());
intgetCurrentQuarter()
get Current Quarter
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String nowDate = sdf.format(new Date());
Calendar cal = Calendar.getInstance();
int currentYear = cal.get(Calendar.YEAR);
if (daysBetween(currentYear + "-4-1", nowDate) < 0) {
    return 1;
} else if (daysBetween(currentYear + "-7-1", nowDate) < 0) {
    return 2;
...
StringgetCurrentSecond()
get Current Second
return getCurrentFormat("ss");
StringgetCurrentString(String pattern)
get Current String
SimpleDateFormat f = new SimpleDateFormat(pattern);
return f.format(Calendar.getInstance(TimeZone.getDefault()).getTime());
StringgetCurrentStringDate()
get Current String Date
return onlyDateFmt.format(getCurrentDate());