Java Utililty Methods Month of Year

List of utility methods to do Month of Year

Description

The list of methods to do Month of Year are organized into topic(s).

Method

voidsleepUntil(int year, int month, int day, int hour, int min, int sec)
Sleeps the current thread until the specified future date.
Calendar cal = Calendar.getInstance();
cal.set(year, month, day, hour, min, sec);
long msFuture = cal.getTime().getTime();
long msNow = System.currentTimeMillis();
long msSleep = msFuture - msNow;
if (msSleep <= 0) {
    return;
try {
    Thread.sleep(msFuture - msNow);
} catch (InterruptedException e) {
    throw new RuntimeException(e);
DatestringToMonth(String year, String month, boolean flag)
string To Month
if (year == null || month == null)
    return null;
Calendar instance = Calendar.getInstance();
if (flag) {
    instance.set(Integer.parseInt(year), Integer.parseInt(month) - 1, 1, 0, 0, 0);
} else {
    instance.set(Integer.parseInt(year), Integer.parseInt(month), 1, 0, 0, 0);
return instance.getTime();
intsumDayByYearMonth(int year, int month)
sum Day By Year Month
Calendar c = Calendar.getInstance();
c.clear();
c.set(1, year);
c.set(2, month - 1);
return c.getActualMaximum(5);
Dateyear(int month, int day, int hour, int minute, int second)
year
Calendar now = now();
return new GregorianCalendar(now.get(Calendar.YEAR), month, day, hour, minute, second).getTime();
StringyearMonth()
year Month
StringBuilder sb = new StringBuilder();
Calendar cal = GregorianCalendar.getInstance();
int monthNum = cal.get(Calendar.MONTH) + 1;
String month = (monthNum > 9) ? "" + monthNum : "0" + monthNum;
sb.append(cal.get(Calendar.YEAR));
sb.append(month);
return sb.toString();