Java Code Examples for java.util.Calendar#NOVEMBER

The following examples show how to use java.util.Calendar#NOVEMBER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From ClockPlus with GNU General Public License v3.0 6 votes vote down vote up
public static int getDaysInMonth(int month, int year) {
    switch (month) {
        case Calendar.JANUARY:
        case Calendar.MARCH:
        case Calendar.MAY:
        case Calendar.JULY:
        case Calendar.AUGUST:
        case Calendar.OCTOBER:
        case Calendar.DECEMBER:
            return 31;
        case Calendar.APRIL:
        case Calendar.JUNE:
        case Calendar.SEPTEMBER:
        case Calendar.NOVEMBER:
            return 30;
        case Calendar.FEBRUARY:
            return (year % 4 == 0) ? 29 : 28;
        default:
            throw new IllegalArgumentException("Invalid Month");
    }
}
 
Example 2
Source File: Utils.java    From cathode with Apache License 2.0 6 votes vote down vote up
public static int getDaysInMonth(int month, int year) {
    switch (month) {
        case Calendar.JANUARY:
        case Calendar.MARCH:
        case Calendar.MAY:
        case Calendar.JULY:
        case Calendar.AUGUST:
        case Calendar.OCTOBER:
        case Calendar.DECEMBER:
            return 31;
        case Calendar.APRIL:
        case Calendar.JUNE:
        case Calendar.SEPTEMBER:
        case Calendar.NOVEMBER:
            return 30;
        case Calendar.FEBRUARY:
            return (year % 4 == 0) ? 29 : 28;
        default:
            throw new IllegalArgumentException("Invalid Month");
    }
}
 
Example 3
Source File: Utils.java    From StyleableDateTimePicker with MIT License 6 votes vote down vote up
public static int getDaysInMonth(int month, int year) {
    switch (month) {
        case Calendar.JANUARY:
        case Calendar.MARCH:
        case Calendar.MAY:
        case Calendar.JULY:
        case Calendar.AUGUST:
        case Calendar.OCTOBER:
        case Calendar.DECEMBER:
            return 31;
        case Calendar.APRIL:
        case Calendar.JUNE:
        case Calendar.SEPTEMBER:
        case Calendar.NOVEMBER:
            return 30;
        case Calendar.FEBRUARY:
            return (year % 4 == 0) ? 29 : 28;
        default:
            throw new IllegalArgumentException("Invalid Month");
    }
}
 
Example 4
Source File: AppCompatDatePickerDelegate.java    From AppCompat-Extension-Library with Apache License 2.0 6 votes vote down vote up
public static int getDaysInMonth(int month, int year) {
    switch (month) {
        case Calendar.JANUARY:
        case Calendar.MARCH:
        case Calendar.MAY:
        case Calendar.JULY:
        case Calendar.AUGUST:
        case Calendar.OCTOBER:
        case Calendar.DECEMBER:
            return 31;
        case Calendar.APRIL:
        case Calendar.JUNE:
        case Calendar.SEPTEMBER:
        case Calendar.NOVEMBER:
            return 30;
        case Calendar.FEBRUARY:
            return (year % 4 == 0) ? 29 : 28;
        default:
            throw new IllegalArgumentException("Invalid Month");
    }
}
 
Example 5
Source File: CalendarUtils.java    From AirCalendar with MIT License 6 votes vote down vote up
public static int getDaysInMonth(int month, int year) {
       switch (month) {
           case Calendar.JANUARY:
           case Calendar.MARCH:
           case Calendar.MAY:
           case Calendar.JULY:
           case Calendar.AUGUST:
           case Calendar.OCTOBER:
           case Calendar.DECEMBER:
               return 31;
           case Calendar.APRIL:
           case Calendar.JUNE:
           case Calendar.SEPTEMBER:
           case Calendar.NOVEMBER:
               return 30;
           case Calendar.FEBRUARY:
               return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 28 : 29;
           default:
               throw new IllegalArgumentException("Invalid Month");
       }
}
 
Example 6
Source File: GregorianCalendarTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_computeTime_enteringDst() {
    // Get the DST entry time with a ZoneInfo implementation of TimeZone.
    TimeZone zoneInfo = TimeZone.getTimeZone("America/Los_Angeles");
    long zoneInfoTime = getDstLosAngeles2014(zoneInfo);

    // Check that the time is correct.
    assertTrue(zoneInfo.inDaylightTime(new Date(zoneInfoTime)));
    assertFalse(zoneInfo.inDaylightTime(new Date(zoneInfoTime - 1)));

    // Get the DST entry time with a SimpleTimeZone implementation of TimeZone.
    SimpleTimeZone simpleTimeZone = new SimpleTimeZone(-28800000,
            "Custom America/Los_Angeles",
            Calendar.MARCH, 9, 0, 7200000,
            Calendar.NOVEMBER, 2, 0, 7200000,
            3600000);
    long simpleTimeZoneTime = getDstLosAngeles2014(simpleTimeZone);

}
 
Example 7
Source File: Utils.java    From narrate-android with Apache License 2.0 6 votes vote down vote up
public static int getDaysInMonth(int month, int year) {
    switch (month) {
        case Calendar.JANUARY:
        case Calendar.MARCH:
        case Calendar.MAY:
        case Calendar.JULY:
        case Calendar.AUGUST:
        case Calendar.OCTOBER:
        case Calendar.DECEMBER:
            return 31;
        case Calendar.APRIL:
        case Calendar.JUNE:
        case Calendar.SEPTEMBER:
        case Calendar.NOVEMBER:
            return 30;
        case Calendar.FEBRUARY:
            return (year % 4 == 0) ? 29 : 28;
        default:
            throw new IllegalArgumentException("Invalid Month");
    }
}
 
Example 8
Source File: SimpleTimeZoneTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testDstNewYork2014_2ndSundayMarch_1stSundayNovember_StandardTime() {
    TimeZone timeZone = new SimpleTimeZone(NEW_YORK_RAW_OFFSET, "EST",
            Calendar.MARCH, 2, Calendar.SUNDAY, 7200000, SimpleTimeZone.STANDARD_TIME,
            Calendar.NOVEMBER, 1, Calendar.SUNDAY, 3600000, SimpleTimeZone.STANDARD_TIME,
            3600000);

    checkDstNewYork2014(timeZone);
}
 
Example 9
Source File: HttpDateTime.java    From travelguide with Apache License 2.0 5 votes vote down vote up
private static int getMonth(String monthString) {
    int hash = Character.toLowerCase(monthString.charAt(0)) +
            Character.toLowerCase(monthString.charAt(1)) +
            Character.toLowerCase(monthString.charAt(2)) - 3 * 'a';
    switch (hash) {
        case 22:
            return Calendar.JANUARY;
        case 10:
            return Calendar.FEBRUARY;
        case 29:
            return Calendar.MARCH;
        case 32:
            return Calendar.APRIL;
        case 36:
            return Calendar.MAY;
        case 42:
            return Calendar.JUNE;
        case 40:
            return Calendar.JULY;
        case 26:
            return Calendar.AUGUST;
        case 37:
            return Calendar.SEPTEMBER;
        case 35:
            return Calendar.OCTOBER;
        case 48:
            return Calendar.NOVEMBER;
        case 9:
            return Calendar.DECEMBER;
        default:
            throw new IllegalArgumentException();
    }
}
 
Example 10
Source File: SimpleTimeZoneTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testDstNewYork2014_9thMarch_2ndNovember_WallTime() {
    TimeZone timeZone = new SimpleTimeZone(NEW_YORK_RAW_OFFSET, "EST",
            Calendar.MARCH, 9, 0, 7200000, SimpleTimeZone.WALL_TIME,
            Calendar.NOVEMBER, 2, 0, 7200000, SimpleTimeZone.WALL_TIME,
            3600000);

    checkDstNewYork2014(timeZone);
}
 
Example 11
Source File: DateUtils.java    From roncoo-pay with Apache License 2.0 5 votes vote down vote up
/**
 *
 * 1 第一季度 2 第二季度 3 第三季度 4 第四季度
 *
 * @param date
 * @return
 */
public static int getSeason(Date date) {

	int season = 0;

	Calendar c = Calendar.getInstance();
	c.setTime(date);
	int month = c.get(Calendar.MONTH);
	switch (month) {
	case Calendar.JANUARY:
	case Calendar.FEBRUARY:
	case Calendar.MARCH:
		season = 1;
		break;
	case Calendar.APRIL:
	case Calendar.MAY:
	case Calendar.JUNE:
		season = 2;
		break;
	case Calendar.JULY:
	case Calendar.AUGUST:
	case Calendar.SEPTEMBER:
		season = 3;
		break;
	case Calendar.OCTOBER:
	case Calendar.NOVEMBER:
	case Calendar.DECEMBER:
		season = 4;
		break;
	default:
		break;
	}
	return season;
}
 
Example 12
Source File: EarthClock.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public String getMonthString() {
	int w = getMonth();
	StringBuilder s = new StringBuilder();
	if (w == Calendar.JANUARY)
		s.append("Jan");
	else if (w == Calendar.FEBRUARY)
		s.append("Feb");
	else if (w == Calendar.MARCH)
		s.append("Mar");
	else if (w == Calendar.APRIL)
		s.append("Apr");
	else if (w == Calendar.MAY)
		s.append("May");
	else if (w == Calendar.JUNE)
		s.append("Jun");
	else if (w == Calendar.JULY)
		s.append("Jul");
	else if (w == Calendar.AUGUST)
		s.append("Aug");
	else if (w == Calendar.SEPTEMBER)
		s.append("Sep");
	else if (w == Calendar.OCTOBER)
		s.append("Oct");
	else if (w == Calendar.NOVEMBER)
		s.append("Nov");
	else if (w == Calendar.DECEMBER)
		s.append("Dec");
	return s.toString();
}
 
Example 13
Source File: SimpleTimeZoneTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * java.util.SimpleTimeZone#clone()
 */
public void test_clone() {
    // Test for method java.lang.Object java.util.SimpleTimeZone.clone()
    SimpleTimeZone st1 = new SimpleTimeZone(1000, "TEST",
            Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER,
            -1, Calendar.SUNDAY, 0);
    SimpleTimeZone stA = new SimpleTimeZone(1, "Gah");
    assertTrue("Clone resulted in same reference", st1.clone() != st1);
    assertTrue("Clone resulted in unequal object", ((SimpleTimeZone) st1
            .clone()).equals(st1));
    assertTrue("Clone resulted in same reference", stA.clone() != stA);
    assertTrue("Clone resulted in unequal object", ((SimpleTimeZone) stA
            .clone()).equals(stA));
}
 
Example 14
Source File: DateUtils.java    From android-utils with MIT License 4 votes vote down vote up
/**
 * Gets abbreviated name of the month from the given date.
 *
 * @param date ISO format date
 * @return Returns the name of the month
 */
public static String getMonthAbbreviated(String date) {
    Date dateDT = parseDate(date);

    if (dateDT == null) {
        return null;
    }

    // Get current date
    Calendar c = Calendar.getInstance();
    // it is very important to
    // set the date of
    // the calendar.
    c.setTime(dateDT);
    int day = c.get(Calendar.MONTH);

    String dayStr = null;

    switch (day) {

        case Calendar.JANUARY:
            dayStr = "Jan";
            break;

        case Calendar.FEBRUARY:
            dayStr = "Feb";
            break;

        case Calendar.MARCH:
            dayStr = "Mar";
            break;

        case Calendar.APRIL:
            dayStr = "Apr";
            break;

        case Calendar.MAY:
            dayStr = "May";
            break;

        case Calendar.JUNE:
            dayStr = "Jun";
            break;

        case Calendar.JULY:
            dayStr = "Jul";
            break;

        case Calendar.AUGUST:
            dayStr = "Aug";
            break;

        case Calendar.SEPTEMBER:
            dayStr = "Sep";
            break;

        case Calendar.OCTOBER:
            dayStr = "Oct";
            break;

        case Calendar.NOVEMBER:
            dayStr = "Nov";
            break;

        case Calendar.DECEMBER:
            dayStr = "Dec";
            break;
    }

    return dayStr;
}
 
Example 15
Source File: DateUtils.java    From android-utils with MIT License 4 votes vote down vote up
/***
 * Gets the name of the month from the given date.
 *
 * @param date ISO format date
 * @return Returns the name of the month
 */
public static String getMonth(String date) {
    Date dateDT = parseDate(date);

    if (dateDT == null) {
        return null;
    }

    // Get current date
    Calendar c = Calendar.getInstance();
    // it is very important to
    // set the date of
    // the calendar.
    c.setTime(dateDT);
    int day = c.get(Calendar.MONTH);

    String dayStr = null;

    switch (day) {

        case Calendar.JANUARY:
            dayStr = "January";
            break;

        case Calendar.FEBRUARY:
            dayStr = "February";
            break;

        case Calendar.MARCH:
            dayStr = "March";
            break;

        case Calendar.APRIL:
            dayStr = "April";
            break;

        case Calendar.MAY:
            dayStr = "May";
            break;

        case Calendar.JUNE:
            dayStr = "June";
            break;

        case Calendar.JULY:
            dayStr = "July";
            break;

        case Calendar.AUGUST:
            dayStr = "August";
            break;

        case Calendar.SEPTEMBER:
            dayStr = "September";
            break;

        case Calendar.OCTOBER:
            dayStr = "October";
            break;

        case Calendar.NOVEMBER:
            dayStr = "November";
            break;

        case Calendar.DECEMBER:
            dayStr = "December";
            break;
    }

    return dayStr;
}
 
Example 16
Source File: MultiCalendarAdapter.java    From holo-calendar with Apache License 2.0 4 votes vote down vote up
/**
 * Get the title for the current position
 *
 * @param position - The position in the ViewPager
 * @return Title: MONTH YEAR -> MARCH 2013
 */
@Override
public String getTitle(final int position) {
    final Context context = mContext;
    final Calendar date = Calendar.getInstance();
    date.setTimeInMillis((mCalendarView.getFirstValidDay().getTimeInMillis()));
    date.add(Calendar.MONTH, position);

    final String month;
    switch(date.get(Calendar.MONTH)) {
        case Calendar.JANUARY:
            month = context.getString(R.string.lib_month_january);
            break;
        case Calendar.FEBRUARY:
            month = context.getString(R.string.lib_month_february);
            break;
        case Calendar.MARCH:
            month = context.getString(R.string.lib_month_march);
            break;
        case Calendar.APRIL:
            month = context.getString(R.string.lib_month_april);
            break;
        case Calendar.MAY:
            month = context.getString(R.string.lib_month_may);
            break;
        case Calendar.JUNE:
            month = context.getString(R.string.lib_month_june);
            break;
        case Calendar.JULY:
            month = context.getString(R.string.lib_month_july);
            break;
        case Calendar.AUGUST:
            month = context.getString(R.string.lib_month_august);
            break;
        case Calendar.SEPTEMBER:
            month = context.getString(R.string.lib_month_september);
            break;
        case Calendar.OCTOBER:
            month = context.getString(R.string.lib_month_october);
            break;
        case Calendar.NOVEMBER:
            month = context.getString(R.string.lib_month_november);
            break;
        default:
        case Calendar.DECEMBER:
            month = context.getString(R.string.lib_month_december);
            break;
    }

    return month + " " + date.get(Calendar.YEAR);
}
 
Example 17
Source File: DateTools.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Date ceilSeason(Date date, Integer adjust) throws Exception {
	Calendar cal = DateUtils.toCalendar(date);
	switch (cal.get(Calendar.MONTH)) {
	case Calendar.JANUARY:
		cal.set(Calendar.MONTH, Calendar.MARCH);
		break;
	case Calendar.FEBRUARY:
		cal.set(Calendar.MONTH, Calendar.MARCH);
		break;
	case Calendar.MARCH:
		cal.set(Calendar.MONTH, Calendar.MARCH);
		break;
	case Calendar.APRIL:
		cal.set(Calendar.MONTH, Calendar.JUNE);
		break;
	case Calendar.MAY:
		cal.set(Calendar.MONTH, Calendar.JUNE);
		break;
	case Calendar.JUNE:
		cal.set(Calendar.MONTH, Calendar.JUNE);
		break;
	case Calendar.JULY:
		cal.set(Calendar.MONTH, Calendar.SEPTEMBER);
		break;
	case Calendar.AUGUST:
		cal.set(Calendar.MONTH, Calendar.SEPTEMBER);
		break;
	case Calendar.SEPTEMBER:
		cal.set(Calendar.MONTH, Calendar.SEPTEMBER);
		break;
	case Calendar.OCTOBER:
		cal.set(Calendar.MONTH, Calendar.DECEMBER);
		break;
	case Calendar.NOVEMBER:
		cal.set(Calendar.MONTH, Calendar.DECEMBER);
		break;
	case Calendar.DECEMBER:
		cal.set(Calendar.MONTH, Calendar.DECEMBER);
		break;
	default:
	}
	if ((null != adjust) && (adjust != 0)) {
		cal.add(Calendar.MONTH, (adjust * 3));
	}
	return DateUtils.ceiling(cal, Calendar.MONTH).getTime();
}
 
Example 18
Source File: Utils.java    From Birdays with Apache License 2.0 4 votes vote down vote up
/**
 * Returns zodiac name of certain date
 */
public static int getZodiacId(long date) {
    int resId = 0;
    dayOfBirthday.setTimeInMillis(date);

    switch (getMonth(dayOfBirthday)) {
        case Calendar.JANUARY:
            resId = getDay(dayOfBirthday) < 21 ? R.string.capricorn : R.string.aquarius;
            break;
        case Calendar.FEBRUARY:
            resId = getDay(dayOfBirthday) < 20 ? R.string.aquarius : R.string.pisces;
            break;
        case Calendar.MARCH:
            resId = getDay(dayOfBirthday) < 21 ? R.string.pisces : R.string.aries;
            break;
        case Calendar.APRIL:
            resId = getDay(dayOfBirthday) < 21 ? R.string.aries : R.string.taurus;
            break;
        case Calendar.MAY:
            resId = getDay(dayOfBirthday) < 22 ? R.string.taurus : R.string.gemini;
            break;
        case Calendar.JUNE:
            resId = getDay(dayOfBirthday) < 22 ? R.string.gemini : R.string.cancer;
            break;
        case Calendar.JULY:
            resId = getDay(dayOfBirthday) < 23 ? R.string.cancer : R.string.leo;
            break;
        case Calendar.AUGUST:
            resId = getDay(dayOfBirthday) < 23 ? R.string.leo : R.string.virgo;
            break;
        case Calendar.SEPTEMBER:
            resId = getDay(dayOfBirthday) < 24 ? R.string.virgo : R.string.libra;
            break;
        case Calendar.OCTOBER:
            resId = getDay(dayOfBirthday) < 24 ? R.string.libra : R.string.scorpio;
            break;
        case Calendar.NOVEMBER:
            resId = getDay(dayOfBirthday) < 23 ? R.string.scorpio : R.string.sagittarius;
            break;
        case Calendar.DECEMBER:
            resId = getDay(dayOfBirthday) < 22 ? R.string.sagittarius : R.string.capricorn;
            break;
    }
    return resId;
}
 
Example 19
Source File: FunnyEasterEgg.java    From QuickShop-Reremake with GNU General Public License v3.0 4 votes vote down vote up
private boolean easterDay() {
    int year = new Date().getYear();
    int a = year % 19,
            b = year / 100,
            c = year % 100,
            d = b / 4,
            e = b % 4,
            g = (8 * b + 13) / 25,
            h = (19 * a + b - d - g + 15) % 30,
            j = c / 4,
            k = c % 4,
            m = (a + 11 * h) / 319,
            r = (2 * e + 2 * j - k - h + m + 32) % 7,
            n = (h - m + r + 90) / 25,
            p = (h - m + r + n + 19) % 32;

    int result;
    switch (n) {
        case 1:
            result = Calendar.JANUARY;
            break;
        case 2:
            result = Calendar.FEBRUARY;
            break;
        case 3:
            result = Calendar.MARCH;
            break;
        case 4:
            result = Calendar.APRIL;
            break;
        case 5:
            result = Calendar.MAY;
            break;
        case 6:
            result = Calendar.JUNE;
            break;
        case 7:
            result = Calendar.JULY;
            break;
        case 8:
            result = Calendar.AUGUST;
            break;
        case 9:
            result = Calendar.SEPTEMBER;
            break;
        case 10:
            result = Calendar.OCTOBER;
            break;
        case 11:
            result = Calendar.NOVEMBER;
            break;
        case 12:
            result = Calendar.DECEMBER;
            break;
        default:
            throw new IllegalStateException("Unexpected value: " + n);
    }
    Date eaterDay = new Date(year, result, p);
    Date currentDate = new Date(System.currentTimeMillis());
    if (currentDate.getYear() == eaterDay.getYear()) {
        if (currentDate.getMonth() == eaterDay.getMonth()) {
            return currentDate.getDay() == eaterDay.getDay();
        }
    }
    return false;
}
 
Example 20
Source File: TimeConstraint.java    From hawkular-alerts with Apache License 2.0 4 votes vote down vote up
private int month(String sMonth) {
    if (isEmpty(sMonth)) {
        return -1;
    }
    if (sMonth.length() < 3) {
        return -1;
    }
    String prefix = sMonth.substring(0, 3).toLowerCase();
    MONTH m = MONTH.fromString(prefix);
    if (m == null) {
        return -1;
    }
    switch (m) {
        case JANUARY:
            return Calendar.JANUARY;
        case FEBRUARY:
            return Calendar.FEBRUARY;
        case MARCH:
            return Calendar.MARCH;
        case APRIL:
            return Calendar.APRIL;
        case MAY:
            return Calendar.MAY;
        case JUNE:
            return Calendar.JUNE;
        case JULY:
            return Calendar.JULY;
        case AUGUST:
            return Calendar.AUGUST;
        case SEPTEMBER:
            return Calendar.SEPTEMBER;
        case OCTOBER:
            return Calendar.OCTOBER;
        case NOVEMBER:
            return Calendar.NOVEMBER;
        case DECEMBER:
            return Calendar.DECEMBER;
        default:
            return -1;
    }
}