Java Code Examples for android.icu.util.Calendar#AUGUST
The following examples show how to use
android.icu.util.Calendar#AUGUST .
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 |
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 |
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 |
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 |
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 |
/** * 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: HolidayTest.java From j2objc with Apache License 2.0 | 4 votes |
@Test public void TestIsOn() { // jb 1901 SimpleHoliday sh = new SimpleHoliday(Calendar.AUGUST, 15, "Doug's Day", 1958, 2058); Calendar gcal = new GregorianCalendar(); gcal.clear(); gcal.set(Calendar.YEAR, 2000); gcal.set(Calendar.MONTH, Calendar.AUGUST); gcal.set(Calendar.DAY_OF_MONTH, 15); Date d0 = gcal.getTime(); gcal.add(Calendar.SECOND, 1); Date d1 = gcal.getTime(); gcal.add(Calendar.SECOND, -2); Date d2 = gcal.getTime(); gcal.add(Calendar.DAY_OF_MONTH, 1); Date d3 = gcal.getTime(); gcal.add(Calendar.SECOND, 1); Date d4 = gcal.getTime(); gcal.add(Calendar.SECOND, -2); gcal.set(Calendar.YEAR, 1957); Date d5 = gcal.getTime(); gcal.set(Calendar.YEAR, 1958); Date d6 = gcal.getTime(); gcal.set(Calendar.YEAR, 2058); Date d7 = gcal.getTime(); gcal.set(Calendar.YEAR, 2059); Date d8 = gcal.getTime(); Date[] dates = { d0, d1, d2, d3, d4, d5, d6, d7, d8 }; boolean[] isOns = { true, true, false, true, false, false, true, true, false }; for (int i = 0; i < dates.length; ++i) { Date d = dates[i]; logln("\ndate: " + d); boolean isOn = sh.isOn(d); logln("isOnDate: " + isOn); if (isOn != isOns[i]) { errln("date: " + d + " should be on Doug's Day!"); } Date h = sh.firstAfter(d); logln("firstAfter: " + h); } }
Example 7
Source File: AstroTest.java From j2objc with Apache License 2.0 | 4 votes |
@Test public void TestCoverage() { GregorianCalendar cal = new GregorianCalendar(1958, Calendar.AUGUST, 15); Date then = cal.getTime(); CalendarAstronomer myastro = new CalendarAstronomer(then); //Latitude: 34 degrees 05' North //Longitude: 118 degrees 22' West double laLat = 34 + 5d/60, laLong = 360 - (118 + 22d/60); CalendarAstronomer myastro2 = new CalendarAstronomer(laLong, laLat); double eclLat = laLat * Math.PI / 360; double eclLong = laLong * Math.PI / 360; Ecliptic ecl = new Ecliptic(eclLat, eclLong); logln("ecliptic: " + ecl); CalendarAstronomer myastro3 = new CalendarAstronomer(); myastro3.setJulianDay((4713 + 2000) * 365.25); CalendarAstronomer[] astronomers = { myastro, myastro2, myastro3, myastro2 // check cache }; for (int i = 0; i < astronomers.length; ++i) { CalendarAstronomer astro = astronomers[i]; logln("astro: " + astro); logln(" time: " + astro.getTime()); logln(" date: " + astro.getDate()); logln(" cent: " + astro.getJulianCentury()); logln(" gw sidereal: " + astro.getGreenwichSidereal()); logln(" loc sidereal: " + astro.getLocalSidereal()); logln(" equ ecl: " + astro.eclipticToEquatorial(ecl)); logln(" equ long: " + astro.eclipticToEquatorial(eclLong)); logln(" horiz: " + astro.eclipticToHorizon(eclLong)); logln(" sunrise: " + new Date(astro.getSunRiseSet(true))); logln(" sunset: " + new Date(astro.getSunRiseSet(false))); logln(" moon phase: " + astro.getMoonPhase()); logln(" moonrise: " + new Date(astro.getMoonRiseSet(true))); logln(" moonset: " + new Date(astro.getMoonRiseSet(false))); logln(" prev summer solstice: " + new Date(astro.getSunTime(CalendarAstronomer.SUMMER_SOLSTICE, false))); logln(" next summer solstice: " + new Date(astro.getSunTime(CalendarAstronomer.SUMMER_SOLSTICE, true))); logln(" prev full moon: " + new Date(astro.getMoonTime(CalendarAstronomer.FULL_MOON, false))); logln(" next full moon: " + new Date(astro.getMoonTime(CalendarAstronomer.FULL_MOON, true))); } }
Example 8
Source File: TimeZoneRegressionTest.java From j2objc with Apache License 2.0 | 4 votes |
/** * SimpleTimeZone.getOffset accepts illegal arguments. */ @Test public void Test4154650() { final int GOOD=1, BAD=0; final int GOOD_ERA=GregorianCalendar.AD, GOOD_YEAR=1998, GOOD_MONTH=Calendar.AUGUST; final int GOOD_DAY=2, GOOD_DOW=Calendar.SUNDAY, GOOD_TIME=16*3600000; int[] DATA = { GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, GOOD_TIME, GOOD, GregorianCalendar.BC, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, GOOD_TIME, GOOD, GregorianCalendar.AD, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, GOOD_TIME, BAD, GregorianCalendar.BC-1, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, GOOD_TIME, BAD, GregorianCalendar.AD+1, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, GOOD_TIME, GOOD, GOOD_ERA, GOOD_YEAR, Calendar.JANUARY, GOOD_DAY, GOOD_DOW, GOOD_TIME, GOOD, GOOD_ERA, GOOD_YEAR, Calendar.DECEMBER, GOOD_DAY, GOOD_DOW, GOOD_TIME, BAD, GOOD_ERA, GOOD_YEAR, Calendar.JANUARY-1, GOOD_DAY, GOOD_DOW, GOOD_TIME, BAD, GOOD_ERA, GOOD_YEAR, Calendar.DECEMBER+1, GOOD_DAY, GOOD_DOW, GOOD_TIME, GOOD, GOOD_ERA, GOOD_YEAR, Calendar.JANUARY, 1, GOOD_DOW, GOOD_TIME, GOOD, GOOD_ERA, GOOD_YEAR, Calendar.JANUARY, 31, GOOD_DOW, GOOD_TIME, BAD, GOOD_ERA, GOOD_YEAR, Calendar.JANUARY, 0, GOOD_DOW, GOOD_TIME, BAD, GOOD_ERA, GOOD_YEAR, Calendar.JANUARY, 32, GOOD_DOW, GOOD_TIME, GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, Calendar.SUNDAY, GOOD_TIME, GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, Calendar.SATURDAY, GOOD_TIME, BAD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, Calendar.SUNDAY-1, GOOD_TIME, BAD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, Calendar.SATURDAY+1, GOOD_TIME, GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, 0, GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, 24*3600000-1, BAD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, -1, BAD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, 24*3600000, }; TimeZone tz = TimeZone.getDefault(); for (int i=0; i<DATA.length; i+=7) { boolean good = DATA[i] == GOOD; IllegalArgumentException e = null; try { /*int offset =*/ tz.getOffset(DATA[i+1], DATA[i+2], DATA[i+3], DATA[i+4], DATA[i+5], DATA[i+6]); //offset = 0; } catch (IllegalArgumentException ex) { e = ex; } if (good != (e == null)) { errln("Fail: getOffset(" + DATA[i+1] + ", " + DATA[i+2] + ", " + DATA[i+3] + ", " + DATA[i+4] + ", " + DATA[i+5] + ", " + DATA[i+6] + (good ? (") threw " + e) : ") accepts invalid args")); } } }
Example 9
Source File: TimeZoneBoundaryTest.java From j2objc with Apache License 2.0 | 4 votes |
/** * Test new rule formats. */ @Test public void TestNewRules() { //logln(Locale.getDefault().getDisplayName()); //logln(TimeZone.getDefault().getID()); //logln(new Date(0)); if (true) { // Doesn't matter what the default TimeZone is here, since we // are creating our own TimeZone objects. SimpleTimeZone tz; java.util.Calendar tempcal = java.util.Calendar.getInstance(); tempcal.clear(); logln("-----------------------------------------------------------------"); logln("Aug 2ndTues .. Mar 15"); tz = new SimpleTimeZone(-8*ONE_HOUR, "Test_1", Calendar.AUGUST, 2, Calendar.TUESDAY, 2*ONE_HOUR, Calendar.MARCH, 15, 0, 2*ONE_HOUR); //logln(tz.toString()); logln("========================================"); tempcal.set(1997, 0, 1); _testUsingBinarySearch(tz, tempcal.getTime(), 858416400000L); logln("========================================"); tempcal.set(1997, 6, 1); _testUsingBinarySearch(tz, tempcal.getTime(), 871380000000L); logln("-----------------------------------------------------------------"); logln("Apr Wed>=14 .. Sep Sun<=20"); tz = new SimpleTimeZone(-8*ONE_HOUR, "Test_2", Calendar.APRIL, 14, -Calendar.WEDNESDAY, 2*ONE_HOUR, Calendar.SEPTEMBER, -20, -Calendar.SUNDAY, 2*ONE_HOUR); //logln(tz.toString()); logln("========================================"); tempcal.set(1997, 0, 1); _testUsingBinarySearch(tz, tempcal.getTime(), 861184800000L); logln("========================================"); tempcal.set(1997, 6, 1); _testUsingBinarySearch(tz, tempcal.getTime(), 874227600000L); } /* if (true) { logln("========================================"); logln("Stepping using millis"); _testUsingMillis(new Date(97,0,1), false); } if (true) { logln("========================================"); logln("Stepping using fields"); _testUsingFields(1997, false); } if (false) { cal.clear(); cal.set(1997, 3, 5, 10, 0); // cal.inDaylightTime(); logln("Date = " + cal.getTime()); logln("Millis = " + cal.getTime().getTime()/3600000); } */ }