List of utility methods to do Date Now
List | getCurrentMonthday() 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); ... |
String | getCurrentMonthLastDay() 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; |
String | getCurrentMonthStartTime() 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);
...
|
String | getCurrentMonthString(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; |
String | getCurrentODSDate() get Current ODS Date return asODSDate(new Date()); |
String | getCurrentPlainDate() Get current date as string in format yyyymmdd return getPlainDateFrom(new Date()); |
int | getCurrentQuarter() 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; ... |
String | getCurrentSecond() get Current Second return getCurrentFormat("ss"); |
String | getCurrentString(String pattern) get Current String SimpleDateFormat f = new SimpleDateFormat(pattern); return f.format(Calendar.getInstance(TimeZone.getDefault()).getTime()); |
String | getCurrentStringDate() get Current String Date return onlyDateFmt.format(getCurrentDate());
|