Java Code Examples for android.icu.util.Calendar#ERA
The following examples show how to use
android.icu.util.Calendar#ERA .
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: DateIntervalFormat.java From j2objc with Apache License 2.0 | 5 votes |
/** * @deprecated This API is ICU internal only. * @hide original deprecated declaration * @hide draft / provisional / internal are hidden on Android */ @Deprecated public String getPatterns(Calendar fromCalendar, Calendar toCalendar, Output<String> part2) { // First, find the largest different calendar field. int field; if ( fromCalendar.get(Calendar.ERA) != toCalendar.get(Calendar.ERA) ) { field = Calendar.ERA; } else if ( fromCalendar.get(Calendar.YEAR) != toCalendar.get(Calendar.YEAR) ) { field = Calendar.YEAR; } else if ( fromCalendar.get(Calendar.MONTH) != toCalendar.get(Calendar.MONTH) ) { field = Calendar.MONTH; } else if ( fromCalendar.get(Calendar.DATE) != toCalendar.get(Calendar.DATE) ) { field = Calendar.DATE; } else if ( fromCalendar.get(Calendar.AM_PM) != toCalendar.get(Calendar.AM_PM) ) { field = Calendar.AM_PM; } else if ( fromCalendar.get(Calendar.HOUR) != toCalendar.get(Calendar.HOUR) ) { field = Calendar.HOUR; } else if ( fromCalendar.get(Calendar.MINUTE) != toCalendar.get(Calendar.MINUTE) ) { field = Calendar.MINUTE; } else if ( fromCalendar.get(Calendar.SECOND) != toCalendar.get(Calendar.SECOND) ) { field = Calendar.SECOND; } else { return null; } PatternInfo intervalPattern = fIntervalPatterns.get( DateIntervalInfo.CALENDAR_FIELD_TO_PATTERN_LETTER[field]); part2.value = intervalPattern.getSecondPart(); return intervalPattern.getFirstPart(); }
Example 2
Source File: JapaneseTest.java From j2objc with Apache License 2.0 | 4 votes |
@Test public void Test5345calendar() { logln("** testIncompleteCalendar()"); // Test calendar with incomplete information JapaneseCalendar c = new JapaneseCalendar(TimeZone.getDefault()); logln("test clear"); c.clear(); // Showa 45 = Gregorian 1970 int expected0[] = { Calendar.ERA, 234, Calendar.YEAR, 45 }; checkExpected(c, expected0); logln("test setting era"); c.clear(); c.set(Calendar.ERA, JapaneseCalendar.MEIJI); int expectedA[] = { Calendar.ERA, JapaneseCalendar.MEIJI }; checkExpected(c, expectedA); logln("test setting era and year and month and date"); c.clear(); c.set(Calendar.ERA, JapaneseCalendar.MEIJI); c.set(Calendar.YEAR, 1); c.set(Calendar.MONTH, Calendar.JANUARY); c.set(Calendar.DATE, 1); int expectedC[] = { Calendar.ERA, JapaneseCalendar.MEIJI -1}; checkExpected(c, expectedC); logln("test setting year and month and date THEN era"); c.clear(); c.set(Calendar.YEAR, 1); c.set(Calendar.MONTH, Calendar.JANUARY); c.set(Calendar.DATE, 1); c.set(Calendar.ERA, JapaneseCalendar.MEIJI); checkExpected(c, expectedC); logln("test setting era and year"); c.clear(); c.set(Calendar.YEAR, 1); c.set(Calendar.ERA, JapaneseCalendar.MEIJI); int expectedB[] = { Calendar.ERA, JapaneseCalendar.MEIJI, Calendar.YEAR, 1 }; checkExpected(c, expectedB); }