/** * Private member function that does the real date/time formatting. * 实际完成格式化工作的方法 */ privatevoidsubFormat(int patternCharIndex, int count, FieldDelegate delegate, StringBuffer buffer, boolean useDateFormatSymbols) { int maxIntCount = Integer.MAX_VALUE; String current = null; int beginOffset = buffer.length();
// 从映射中拿到Calendar的field索引值 int field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex]; int value; if (field == CalendarBuilder.WEEK_YEAR) { if (calendar.isWeekDateSupported()) { value = calendar.getWeekYear(); } else { // use calendar year 'y' instead patternCharIndex = PATTERN_YEAR; field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex]; value = calendar.get(field); } } elseif (field == CalendarBuilder.ISO_DAY_OF_WEEK) { value = CalendarBuilder.toISODayOfWeek(calendar.get(Calendar.DAY_OF_WEEK)); } else { // 获取真实值 value = calendar.get(field); }