protected NumberRule selectNumberRule(final int field, final int padding) { switch (padding) { case 1: return new UnpaddedNumberField(field); case 2: return new TwoDigitNumberField(field); default: return new PaddedNumberField(field, padding); } }
protected FastDateFormat(final String pattern, final TimeZone timeZone, final Locale locale, final Date centuryStart) { printer = new FastDatePrinter(pattern, timeZone, locale); parser = new FastDateParser(pattern, timeZone, locale, centuryStart); }
@Override public void appendTo(final StringBuffer buffer, final int value) { mRule.appendTo(buffer, value); } }
private Strategy getLocaleSpecificStrategy(final int field, final Calendar definingCalendar) { final ConcurrentMap<Locale, Strategy> cache = getCache(field); Strategy strategy = cache.get(locale); if (strategy == null) { strategy = field == Calendar.ZONE_OFFSET ? new TimeZoneStrategy(locale) : new TextStrategy(field, definingCalendar, locale); final Strategy inCache = cache.putIfAbsent(locale, strategy); if (inCache != null) { return inCache; } } return strategy; }
/** * 方法描述:格式化日期 */ public static String formatDate(Date d, String fmt) { return FastDateFormat.getInstance(fmt).format(d); }
private void init() { final List<Rule> rulesList = parsePattern(); mRules = rulesList.toArray(new Rule[rulesList.size()]); int len = 0; for (int i=mRules.length; --i >= 0; ) { len += mRules[i].estimateLength(); } mMaxLengthEstimate = len; }
TimeZoneNameRule(final TimeZone timeZone, final Locale locale, final int style) { mLocale = locale; mStyle = style; mStandard = getTimeZoneDisplay(timeZone, false, style, locale); mDaylight = getTimeZoneDisplay(timeZone, true, style, locale); }
protected StringBuffer applyRules(final Calendar calendar, final StringBuffer buf) { for (final Rule rule : mRules) { rule.appendTo(buf, calendar); } return buf; }
protected FastDatePrinter(final String pattern, final TimeZone timeZone, final Locale locale) { mPattern = pattern; mTimeZone = timeZone; mLocale = locale; init(); }
@Override public int estimateLength() { return mRule.estimateLength(); }
protected NumberRule selectNumberRule(final int field, final int padding) { switch (padding) { case 1: return new UnpaddedNumberField(field); case 2: return new TwoDigitNumberField(field); default: return new PaddedNumberField(field, padding); } }
protected FastDateFormat(final String pattern, final TimeZone timeZone, final Locale locale, final Date centuryStart) { printer = new FastDatePrinter(pattern, timeZone, locale); parser = new FastDateParser(pattern, timeZone, locale, centuryStart); }
/** * 方法描述:格式化日期 */ public static String formatDate(Date d, String fmt) { return FastDateFormat.getInstance(fmt).format(d); }
@Override public void appendTo(final StringBuffer buffer, final int value) { mRule.appendTo(buffer, value); } }
TimeZoneNameRule(final TimeZone timeZone, final Locale locale, final int style) { mLocale = locale; mStyle = style; mStandard = getTimeZoneDisplay(timeZone, false, style, locale); mDaylight = getTimeZoneDisplay(timeZone, true, style, locale); }
protected StringBuffer applyRules(final Calendar calendar, final StringBuffer buf) { for (final Rule rule : mRules) { rule.appendTo(buf, calendar); } return buf; }
protected FastDatePrinter(final String pattern, final TimeZone timeZone, final Locale locale) { mPattern = pattern; mTimeZone = timeZone; mLocale = locale; init(); }
@Override public int estimateLength() { return mRule.estimateLength(); }
@Override public void appendTo(final StringBuffer buffer, final int value) { mRule.appendTo(buffer, value); } }
@Override public void appendTo(final StringBuffer buffer, final int value) { mRule.appendTo(buffer, value); } }