Java Month of Year get_NextSunday_YearMonthDay_integerArray()

Here you can find the source of get_NextSunday_YearMonthDay_integerArray()

Description

ge Next Sunda Year Month Dainteger Array

License

Open Source License

Declaration

@SuppressWarnings("deprecation")
    public static int[] get_NextSunday_YearMonthDay_integerArray() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Date;

public class Main {
    @SuppressWarnings("deprecation")
    public static int[] get_NextSunday_YearMonthDay_integerArray() {

        Date objDateLocal = new Date();
        Calendar objCalendarLocal = Calendar.getInstance();

        int nLocal_DD = 0;
        int nLocal_MM = 0;

        objCalendarLocal.setTime(objDateLocal);
        nLocal_DD = objCalendarLocal.get(Calendar.DATE);
        nLocal_MM = objCalendarLocal.get(Calendar.MONTH);
        int nLocal_MaxDayCount = objCalendarLocal
                .getActualMaximum(Calendar.DAY_OF_MONTH);

        if (nLocal_MM == 1) { // Feb is actually 1
            if (nLocal_DD > 23) {
                objCalendarLocal.set(Calendar.MONTH, Calendar.MONTH + 1);
                objDateLocal.setMonth(objCalendarLocal.get(Calendar.MONTH));
            }//from  www  .  j  a v a 2  s.  c  o m
        } else {
            if (nLocal_DD > 25 && nLocal_MaxDayCount == 31) {
                objCalendarLocal.set(Calendar.MONTH, Calendar.MONTH + 1);
                objDateLocal.setMonth(objCalendarLocal.get(Calendar.MONTH));
                nLocal_MM = objDateLocal.getMonth();
                if (nLocal_MM > 11) {
                    objCalendarLocal.set(Calendar.YEAR, Calendar.YEAR + 1);
                    objDateLocal.setYear(objCalendarLocal
                            .get(Calendar.YEAR));
                }
            }
            if (nLocal_DD > 24 && nLocal_MaxDayCount == 30) {
                objCalendarLocal.set(Calendar.MONTH, Calendar.MONTH + 1);
                objDateLocal.setMonth(objCalendarLocal.get(Calendar.MONTH));
            }
        }
        objCalendarLocal.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
        objDateLocal.setDate(objCalendarLocal.get(Calendar.DATE) + 9);
        objCalendarLocal.setTime(objDateLocal);

        int[] nArr_Current_YearMonthDay = {
                objCalendarLocal.get(Calendar.YEAR),
                objCalendarLocal.get(Calendar.MONTH) + 1, // due to Java implementation need to add +1 to months count
                objCalendarLocal.get(Calendar.DATE) };
        return nArr_Current_YearMonthDay;
    }
}

Related

  1. daysInMonth(final int year, final int month)
  2. daysInMonth(int month, int year)
  3. daysInMonth(int month, int year)
  4. daysInMonth(int year, int month)
  5. daysInMonth(int year, int month)
  6. getActualMonthBefore(int year, int month, int i)
  7. getCalforMonth(String month, String year)
  8. getDaysByYearMonth(int year, int month)
  9. getDefaultHolidays(int year, int month)