List of utility methods to do Month of Year
String | getFirstMonthOfThisYear() get First Month Of This Year Calendar calendar = Calendar.getInstance(); curYear = calendar.get(Calendar.YEAR); date = "" + curYear + "01"; return date; |
java.util.Calendar | getFirstTimeOfDay(int year, int month, int day) get First Time Of Day Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month - 1);
cal.set(Calendar.DAY_OF_MONTH, day);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
return cal;
...
|
Map | getLastCompletedMonthAndYear() get Last Completed Month And Year final Calendar now = Calendar.getInstance(); int month = now.get(Calendar.MONTH); int year = now.get(Calendar.YEAR); if (month == 0) { month = 12; year--; } else { month--; ... |
String | getLastMonth() get Last Month GregorianCalendar now = new GregorianCalendar(); now.add(2, -1); return format(now.getTime(), "yyyyMM"); |
String | getLastMonth() get Last Month final Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, -1); final Date date = calendar.getTime(); final SimpleDateFormat formatter = new SimpleDateFormat("yyyyMM"); return formatter.format((date)); |
String | getLastMonth() get Last Month Calendar a = Calendar.getInstance(); a.setTime(new Date()); a.set(Calendar.DAY_OF_MONTH, -1); return monthFormat.format(a.getTime()); |
int[] | getLastMonthAndCycle() get Last Month And Cycle int[] o = new int[2]; String day = (getThisMonthAndCycle()[0] + "").substring(4, 6); int year = Integer.parseInt((getThisMonthAndCycle()[0] + "").substring(0, 4)); int month = getThisMonthAndCycle()[0]; int cycle = 0; if (getThisMonthAndCycle()[1] == 1) { if ("01".equals(day)) { year--; ... |
Date | getLastMonthdate() get Last Monthdate car.setTimeInMillis(System.currentTimeMillis());
return addMonth(-1);
|
String | getLastMonthDate() get Last Month Date DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); c.add(Calendar.MONTH, -1); return dateFormat.format(c.getTime()); |
int | getLastMonthDate(int date) get Last Month Date Calendar calendar = Calendar.getInstance(); int year = Integer.parseInt(String.valueOf(date).substring(0, 4)); int month = Integer.parseInt(String.valueOf(date).substring(4, 6)); int day = Integer.parseInt(String.valueOf(date).substring(6, 8)); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, day); calendar.add(Calendar.MONTH, -1); ... |