List of utility methods to do Month Convert
int | monthNumber(String s) returns 1,2,...,12 for the English month name. if (s.length() < 3) throw new ParseException("need at least three letters", 0); s = s.substring(0, 3); for (int i = 0; i < 12; i++) { if (s.equalsIgnoreCase(mons[i])) return i + 1; throw new ParseException("Unable to parse month", 0); ... |
int | monthOfDate(Date s) month Of Date String d = FORMAT_YYYY_MM_DD.format(s);
return Integer.parseInt(d.substring(5, 7));
|
int | monthsBetween(String from, String to) months Between method return monthsBetween(from, to, "yyyyMMdd"); |
int | monthStringToInt(String month) Converts a month title (like "December") into its equivalent number (12). DateFormatSymbols df = new DateFormatSymbols(); int i = 0; for (String mon : df.getMonths()) { if (mon.equalsIgnoreCase(month)) return i + 1; i++; return -1; ... |
int | nextMonth() next Month String next = format(new Date(), "M"); int nextMonth = Integer.parseInt(next) + 1; if (nextMonth == 13) return 1; return nextMonth; |
Date | nextMonth(Date date) next Month Calendar temp = Calendar.getInstance(); temp.setTime(date); int y = temp.get(Calendar.YEAR); int m = temp.get(Calendar.MONTH) + 1; int d = temp.get(Calendar.DAY_OF_MONTH); String sj1 = ""; if (d >= 1 && d <= 20) { d = 21; ... |
Date | nextMonth(Date date) next Month Calendar c = new GregorianCalendar(); c.setTime(date); c.add(Calendar.MONTH, 1); return c.getTime(); |
Date | parseMonth(final String source) Parse the Date using pattern "yyyy-MM" if (source == null || source.trim().length() == 0) { return null; return monthFormat.parse(source); |
Date | setMonths(Date date, int amount) Sets the months field to a date returning a new object. return set(date, Calendar.MONTH, amount);
|