List of utility methods to do Month of Year
Calendar | create(final int year, final int month, final int day) create return create(year, month, day, 0, 0, 0);
|
Date | create(int year, int month, int day) Create a (truncated) date object from year, month, day. Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, day); validate(year, month, day, calendar); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); ... |
Date | create(int year, int month, int day, int hour, int minute, int second) create Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, day, hour, minute, second);
calendar.set(Calendar.MILLISECOND, 0);
Date expected = calendar.getTime();
return expected;
|
String | createKey(int instance, int year, int month, int day, int hour, int min, int sec, int milli, String uuid, boolean rolling) Create a key from all of the parts. String roll = rolling ? ROLLING : ""; return String.format(KEY_TEMPLATE, getInstancePrefix(instance), getDateString(year, month, day), hour, min, sec, milli, uuid, roll); |
long | createTimestamp(int year, int month, int day, int hour, int minutes, int seconds) create Timestamp Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minutes); calendar.set(Calendar.SECOND, seconds); ... |
int | currentYearMonth() current Year Month Calendar c = Calendar.getInstance();
return formatDateIntValue(c.getTime(), YYYYMMINTFORMAT);
|
int | dayOfYear(int year, int month, int day) day Of Year return getCalendar(year, month, day).get(Calendar.DAY_OF_YEAR);
|
int | dayOfYear(int year, int month, int day) day Of Year Calendar c = Calendar.getInstance();
c.set(year, month - 1, day);
return c.get(c.DAY_OF_YEAR);
|
int | daysInMonth(final int month, final int year) days In Month final Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); return calendar.getActualMaximum(Calendar.DATE); |
int | daysInMonth(final int year, final int month) Get the number of days in that month. Calendar cal = Calendar.getInstance();
cal.set(year, month, 1);
return cal.getActualMaximum(Calendar.DAY_OF_MONTH);
|