List of utility methods to do Year Month
Date | getStartMonth(int year, int month) get Start Month Calendar calendar = Calendar.getInstance();
calendar.set(year, month, 1);
return getStartDate(calendar.getTime());
|
Calendar | getTheLastDayOfTheMonth(int year, int month) get The Last Day Of The Month Calendar cal = new GregorianCalendar(); cal.set(year, month, 1); return new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH) - 1); |
String | getThisYearMonth() get This Year Month return getYearMonth(new Date()); |
int | getThisYearMonth() get This Year Month Calendar today = Calendar.getInstance();
return (today.get(Calendar.YEAR)) * 100 + today.get(Calendar.MONTH) + 1;
|
long | getTimeByYearMonth(String yearMonth, String timeZone) get Time By Year Month SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { simpleDateFormat.setTimeZone(TimeZone.getTimeZone(timeZone)); Date date = simpleDateFormat.parse(yearMonth + "-01 00:00:00"); return date.getTime(); } catch (ParseException ex) { System.out.println("Exception " + ex); return 0L; |
String | getYearAndMonth() get Year And Month return toString(new Date(), PATTERN_YYYYMM); |
long | getYearMonth() get Year Month return getYearMonth(new Date()); |
String | getYearMonth() get Year Month String yearMonth = ""; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); yearMonth = sdf.format(new java.util.Date()); return yearMonth; |
String | getYearMonth(Calendar sDate) get Year Month if (sDate == null) return ""; return (new java.text.SimpleDateFormat("yyyy-MM")).format(sDate.getTime()); |
String | getYearMonth(Date date) get Year Month if (null == date) { return null; SimpleDateFormat yearFormat = new SimpleDateFormat("yyyyMM"); return yearFormat.format(date); |