public static int getDayOfYear(Calendar cal, int type) {
        int jday = cal.get(Calendar.DAY_OF_YEAR);
        int mo = cal.get(java.util.Calendar.MONTH) + 1;
        if (type == CALENDAR_YEAR) {
            return jday;
        } else if (type == SOLAR_YEAR) {
            int day = cal.get(Calendar.DAY_OF_MONTH);
            return (mo == 12 && day > 21) ? (day - 21) : (jday + 10);
        } else if (type == WATER_YEAR) {
            return (mo > 9) ? (jday - (isLeapYear(cal.get(Calendar.YEAR)) ? 274 : 273)) : (jday + 92);
        }
        throw new IllegalArgumentException("getDayOfYear() type argument unknown");
    }