List of utility methods to do Year Month
Date | addDate(Calendar cal, int year, int month, int day) add Date int y = cal.get(Calendar.YEAR); int m = cal.get(Calendar.MONTH); int d = cal.get(Calendar.DATE); cal.set(y + year, m + month, d + day); return cal.getTime(); |
int | AddMonths(int yearMonth, int interval) Add Months int result = 0; java.util.Date ym; SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM"); ym = sdf.parse(String.valueOf(yearMonth)); Calendar cal = Calendar.getInstance(); cal.setTime(ym); cal.add(Calendar.MONTH, interval); result = Integer.parseInt(sdf.format(cal.getTime())); ... |
Date | calculatorDate(int incrementYear, int incrementMonth, int incrementDay, int incrementHour, int incrementMin, int incrementSec) calculator Date Calendar c = Calendar.getInstance(); if (incrementYear != 0) { c.add(Calendar.YEAR, incrementYear); if (incrementMonth != 0) { c.add(Calendar.MONTH, incrementMonth); if (incrementDay != 0) { ... |
Calendar | createCalendar(int year, int month, int date, int hour, int minute, int second) create Calendar final Calendar c = new GregorianCalendar(TimeZone.getTimeZone("UTC"), Locale.ENGLISH); c.clear(); c.set(year, month, date, hour, minute, second); return c; |
Date | createDate(final int year, final int month, final int day, final int hour, final int minutes, final int seconds, final int miliseconds) create Date final Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DATE, day);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minutes);
calendar.set(Calendar.SECOND, seconds);
calendar.set(Calendar.MILLISECOND, miliseconds);
...
|
Date | createDate(int year, int month, int day) create Date Calendar c = new GregorianCalendar(); c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, month - 1); c.set(Calendar.DAY_OF_MONTH, day); return startOfDay(c.getTime()); |
Date | createDate(int year, int month, int dayOfMonth) create Date CALENDAR.set(Calendar.YEAR, year);
CALENDAR.set(Calendar.MONTH, month);
CALENDAR.set(Calendar.DAY_OF_MONTH, dayOfMonth);
return CALENDAR.getTime();
|
Date | date(final int year, final int month, final int day, final int hour, final int minute, final int second) date return new GregorianCalendar(year, month - 1, day, hour, minute, second).getTime(); |
Date | date(int year, int month, int day) Convenience method to create a new date return date(year, month, day, 0, 0, 0);
|
long | Date2Long(int year, int month, int date) Date Long Calendar cld = Calendar.getInstance();
month = month - 1;
cld.set(year, month, date);
return cld.getTime().getTime();
|