Java Code Examples for android.icu.util.Calendar#JULY

The following examples show how to use android.icu.util.Calendar#JULY . 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: DatePickerCalendarDelegate.java    From android_9.0.0_r45 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 2
Source File: SimpleMonthView.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private 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: DatePickerCalendarDelegate.java    From DateTimePicker 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 4
Source File: SimpleMonthView.java    From DateTimePicker with Apache License 2.0 6 votes vote down vote up
private 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: IBMCalendarTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Verify that JapaneseCalendar shifts years to Japanese Eras but otherwise
 * behaves like GregorianCalendar.
 */
@Test
public void TestJapanese() {
    // First make sure this test works for GregorianCalendar
    int[] control = {
        GregorianCalendar.AD, 1868, 1868, Calendar.SEPTEMBER, 8,
        GregorianCalendar.AD, 1868, 1868, Calendar.SEPTEMBER, 9,
        GregorianCalendar.AD, 1869, 1869, Calendar.JUNE, 4,
        GregorianCalendar.AD, 1912, 1912, Calendar.JULY, 29,
        GregorianCalendar.AD, 1912, 1912, Calendar.JULY, 30,
        GregorianCalendar.AD, 1912, 1912, Calendar.AUGUST, 1,
    };
    quasiGregorianTest(new GregorianCalendar(), control);

    int[] data = {
        JapaneseCalendar.MEIJI, 1, 1868, Calendar.SEPTEMBER, 8,
        JapaneseCalendar.MEIJI, 1, 1868, Calendar.SEPTEMBER, 9,
        JapaneseCalendar.MEIJI, 2, 1869, Calendar.JUNE, 4,
        JapaneseCalendar.MEIJI, 45, 1912, Calendar.JULY, 29,
        JapaneseCalendar.TAISHO, 1, 1912, Calendar.JULY, 30,
        JapaneseCalendar.TAISHO, 1, 1912, Calendar.AUGUST, 1,
    };
    quasiGregorianTest(new JapaneseCalendar(), data);
}
 
Example 6
Source File: TimeZoneRuleTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void TestT6669() {
    // getNext/PreviousTransition implementation in SimpleTimeZone
    // used to use a bad condition for detecting if DST is enabled or not.

    SimpleTimeZone stz = new SimpleTimeZone(0, "CustomID",
            Calendar.JANUARY, 1, Calendar.SUNDAY, 0,
            Calendar.JULY, 1, Calendar.SUNDAY, 0);

    long t = 1230681600000L; //2008-12-31T00:00:00
    long expectedNext = 1231027200000L; //2009-01-04T00:00:00
    long expectedPrev = 1215298800000L; //2008-07-06T00:00:00

    TimeZoneTransition tzt = stz.getNextTransition(t, false);
    if (tzt == null) {
        errln("FAIL: No transition returned by getNextTransition.");
    } else if (tzt.getTime() != expectedNext){
        errln("FAIL: Wrong transition time returned by getNextTransition - "
                + tzt.getTime() + " Expected: " + expectedNext);
    }

    tzt = stz.getPreviousTransition(t, true);
    if (tzt == null) {
        errln("FAIL: No transition returned by getPreviousTransition.");
    } else if (tzt.getTime() != expectedPrev){
        errln("FAIL: Wrong transition time returned by getPreviousTransition - "
                + tzt.getTime() + " Expected: " + expectedPrev);
    }
}