Java Utililty Methods Date to Month

List of utility methods to do Date to Month

Description

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

Method

intgetMonth(java.util.Date date)
get Month
java.util.Calendar c = java.util.Calendar.getInstance();
c.setTime(date);
return c.get(java.util.Calendar.MONTH) + 1;
IntegergetMonth(java.util.Date today)
getMonth: returns the year of the date
if (today != null) {
    java.util.Calendar c = java.util.Calendar.getInstance(Locale.GERMANY);
    c.setTime(today);
    return c.get(Calendar.MONTH);
} else {
    return null;
longgetMonth(long date, int increment)
get Month
long result;
Calendar calendar = CALENDAR;
synchronized (calendar) {
    calendar.setTimeInMillis(date);
    if (increment == -1) {
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        result = startOfDayInMillis(calendar.getTimeInMillis());
    } else {
...
intgetMonth(String strDate)
get Month
Calendar cal = parseDateTime(strDate);
return cal.get(Calendar.MONTH) + 1;
DategetMonthBeginDate()
get Month Begin Date
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_MONTH, 1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
return c.getTime();
intgetMonthBetween(Date data1, Date data2)
get Month Between
Calendar ca1 = Calendar.getInstance();
Calendar ca2 = Calendar.getInstance();
ca1.setTime(data1);
ca2.setTime(data2);
return ca2.get(Calendar.MONTH) - ca1.get(Calendar.MONTH);
DategetMonthByOffset(Date date, int offset)
get Month By Offset
Calendar calendar = Calendar.getInstance();
if (null != date) {
    calendar.setTime(date);
    calendar.set(5, 1);
    calendar.set(11, 0);
    calendar.set(12, 0);
    calendar.set(13, 0);
    calendar.set(14, 0);
...
int[][]getMonthDays(String date)
get Month Days
int[][] months = new int[6][7];
int days = 1;
int year = getYear(date);
int month = getMonth(date);
int day = getDate(date);
for (int i = getFirstDayOfWeek(year, month); i < 7; i++) {
    months[0][i] = days;
    days++;
...
DategetMonthFirstDay(Date date)
get Month First Day
return getDate(getDateYear(date), getDateMonth(date), 1);
StringgetMonthFromDate(Date date)
get Month From Date
if (date == null) {
    return null;
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return String.valueOf(cal.get(Calendar.MONTH));