Java Month issueMonth(int issue1, int issue2)

Here you can find the source of issueMonth(int issue1, int issue2)

Description

issue Month

License

Open Source License

Declaration

public static int[] issueMonth(int issue1, int issue2) 

Method Source Code

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

public class Main {

    public static int[] issueMonth(int issue1, int issue2) {
        int k = issue1;
        issue1 = k >= issue2 ? k : issue2;
        issue2 = k < issue2 ? k : issue2;
        int months = issueMonthNum(issue1, issue2);
        int[] intArray = new int[months + 1];
        intArray[0] = issue2;//from   w ww. j a v  a2s  .c om
        intArray[months] = issue1;
        int year = issue2 / 100;
        int month = issue2 % 100;
        for (int i = 1; i < months; i++) {
            month++;
            if (month > 12) {
                year++;
                month = 1;
            }
            intArray[i] = Integer.valueOf("" + year + (month < 10 ? "0" + month : month));
        }
        return intArray;
    }

    public static int issueMonthNum(int issue1, int issue2) {
        int k = issue1;
        issue1 = k >= issue2 ? k : issue2;
        issue2 = k < issue2 ? k : issue2;
        int yearnum = issue1 / 100 - issue2 / 100;
        int monthnum = issue1 % 100 - issue2 % 100;
        if (monthnum < 0)
            return 12 * (yearnum - 1) + (12 + monthnum);
        else if (monthnum > 0)
            return 12 * yearnum + monthnum;
        else
            return 12 * yearnum;
    }
}

Related

  1. intToMonth(int m)
  2. isMonthInRange(int month)
  3. isNumMonth(int m)
  4. isQuarterMonth(String[] types)
  5. isSameMonth(String preMonth, String month)
  6. issueMonthNum(int issue1, int issue2)
  7. isValidMonth(int month)
  8. isValidObjectModelMonth(int aMonth)
  9. isWeekOfMonth(int num)