class FastDatePrinter extends AbstractDateBasic implements DatePrinter
| 限定符和类型 | 类和说明 |
|---|---|
private static class |
FastDatePrinter.CharacterLiteral
Inner class to output a constant single character.
|
private static class |
FastDatePrinter.DayInWeekField
Inner class to output the numeric day in week.
|
private static class |
FastDatePrinter.Iso8601_Rule
Inner class to output a time zone as a number
+/-HHMM or +/-HH:MM. |
private static interface |
FastDatePrinter.NumberRule
Inner class defining a numeric rule.
|
private static class |
FastDatePrinter.PaddedNumberField
Inner class to output a padded number.
|
private static interface |
FastDatePrinter.Rule
规则
|
private static class |
FastDatePrinter.StringLiteral
Inner class to output a constant string.
|
private static class |
FastDatePrinter.TextField
Inner class to output one of a set of values.
|
private static class |
FastDatePrinter.TimeZoneDisplayKey
Inner class that acts as a compound key for time zone names.
|
private static class |
FastDatePrinter.TimeZoneNameRule
Inner class to output a time zone name.
|
private static class |
FastDatePrinter.TimeZoneNumberRule
Inner class to output a time zone as a number
+/-HHMM or +/-HH:MM. |
private static class |
FastDatePrinter.TwelveHourField
Inner class to output the twelve hour field.
|
private static class |
FastDatePrinter.TwentyFourHourField
Inner class to output the twenty four hour field.
|
private static class |
FastDatePrinter.TwoDigitMonthField
Inner class to output a two digit month.
|
private static class |
FastDatePrinter.TwoDigitNumberField
Inner class to output a two digit number.
|
private static class |
FastDatePrinter.TwoDigitYearField
Inner class to output a two digit year.
|
private static class |
FastDatePrinter.UnpaddedMonthField
Inner class to output an unpadded month.
|
private static class |
FastDatePrinter.UnpaddedNumberField
Inner class to output an unpadded number.
|
private static class |
FastDatePrinter.WeekYear
Inner class to output the numeric day in week.
|
| 限定符和类型 | 字段和说明 |
|---|---|
private static ConcurrentMap<FastDatePrinter.TimeZoneDisplayKey,String> |
cTimeZoneDisplayCache |
private static int |
MAX_DIGITS |
private int |
mMaxLengthEstimate
估算最大长度.
|
private FastDatePrinter.Rule[] |
rules
规则列表.
|
private static long |
serialVersionUID |
locale, pattern, timeZone| 限定符 | 构造器和说明 |
|---|---|
protected |
FastDatePrinter(String pattern,
TimeZone timeZone,
Locale locale)
构造,内部使用
|
| 限定符和类型 | 方法和说明 |
|---|---|
private static void |
appendDigits(Appendable buffer,
int value)
Appends two digits to the given buffer.
|
private static void |
appendFullDigits(Appendable buffer,
int value,
int minFieldWidth)
Appends all digits to the given buffer.
|
private <B extends Appendable> |
applyRules(Calendar calendar,
B buf)
Performs the formatting by applying the rules to the specified calendar.
|
private String |
applyRulesToString(Calendar c)
Creates a String representation of the given Calendar by applying the rules of this printer to it.
|
String |
format(Calendar calendar)
Formats a
Calendar object. |
<B extends Appendable> |
format(Calendar calendar,
B buf)
Formats a
Calendar object into the supplied Appendable. |
String |
format(Date date)
使用
GregorianCalendar 格式化 Date |
<B extends Appendable> |
format(Date date,
B buf)
Formats a
Date object into the supplied Appendable using a GregorianCalendar. |
String |
format(long millis)
格式化日期表示的毫秒数
|
<B extends Appendable> |
format(long millis,
B buf)
Formats a millisecond
long value into the supplied Appendable. |
(专用程序包) String |
format(Object obj)
Formats a
Date, Calendar or Long (milliseconds) object. |
int |
getMaxLengthEstimate()
估算生成的日期字符串长度
实际生成的字符串长度小于或等于此值 |
(专用程序包) static String |
getTimeZoneDisplay(TimeZone tz,
boolean daylight,
int style,
Locale locale)
Gets the time zone display name, using a cache for performance.
|
private void |
init()
初始化
|
protected List<FastDatePrinter.Rule> |
parsePattern()
Returns a list of Rules given a pattern.
|
protected String |
parseToken(String pattern,
int[] indexRef)
Performs the parsing of tokens.
|
private void |
readObject(ObjectInputStream in)
Create the object after serialization.
|
protected FastDatePrinter.NumberRule |
selectNumberRule(int field,
int padding)
Gets an appropriate rule for the padding required.
|
equals, getLocale, getPattern, getTimeZone, hashCode, toStringgetLocale, getPattern, getTimeZoneprivate static final long serialVersionUID
private transient FastDatePrinter.Rule[] rules
private transient int mMaxLengthEstimate
private static final int MAX_DIGITS
private static final ConcurrentMap<FastDatePrinter.TimeZoneDisplayKey,String> cTimeZoneDisplayCache
private void init()
protected List<FastDatePrinter.Rule> parsePattern()
Returns a list of Rules given a pattern.
List of Rule objectsIllegalArgumentException - if pattern is invalidprotected String parseToken(String pattern, int[] indexRef)
Performs the parsing of tokens.
pattern - the patternindexRef - index referencesprotected FastDatePrinter.NumberRule selectNumberRule(int field, int padding)
Gets an appropriate rule for the padding required.
field - the field to get a rule forpadding - the padding requiredString format(Object obj)
Formats a Date, Calendar or Long (milliseconds) object.
obj - the object to formatpublic String format(long millis)
DatePrinterformat 在接口中 DatePrintermillis - 日期毫秒数public String format(Date date)
DatePrinterGregorianCalendar 格式化 Dateformat 在接口中 DatePrinterdate - 日期 Datepublic String format(Calendar calendar)
DatePrinter
Formats a Calendar object.
Calendarformat 在接口中 DatePrintercalendar - Calendarpublic <B extends Appendable> B format(long millis, B buf)
DatePrinter
Formats a millisecond long value into the supplied Appendable.
format 在接口中 DatePrinterB - the Appendable class type, usually StringBuilder or StringBuffer.millis - the millisecond value to formatbuf - the buffer to format intopublic <B extends Appendable> B format(Date date, B buf)
DatePrinter
Formats a Date object into the supplied Appendable using a GregorianCalendar.
format 在接口中 DatePrinterB - the Appendable class type, usually StringBuilder or StringBuffer.date - the date to formatbuf - the buffer to format intopublic <B extends Appendable> B format(Calendar calendar, B buf)
DatePrinter
Formats a Calendar object into the supplied Appendable.
format 在接口中 DatePrinterB - the Appendable class type, usually StringBuilder or StringBuffer.calendar - the calendar to formatbuf - the buffer to format intoprivate String applyRulesToString(Calendar c)
c - the Calender to apply the rules to.private <B extends Appendable> B applyRules(Calendar calendar, B buf)
Performs the formatting by applying the rules to the specified calendar.
B - the Appendable class type, usually StringBuilder or StringBuffer.calendar - the calendar to formatbuf - the buffer to format intopublic int getMaxLengthEstimate()
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
in - ObjectInputStream from which the object is being deserialized.IOException - if there is an IO issue.ClassNotFoundException - if a class cannot be found.private static void appendDigits(Appendable buffer, int value) throws IOException
buffer - the buffer to append to.value - the value to append digits from.IOExceptionprivate static void appendFullDigits(Appendable buffer, int value, int minFieldWidth) throws IOException
buffer - the buffer to append to.value - the value to append digits from.IOExceptionstatic String getTimeZoneDisplay(TimeZone tz, boolean daylight, int style, Locale locale)
Gets the time zone display name, using a cache for performance.
tz - the zone to querydaylight - true if daylight savingsstyle - the style to use TimeZone.LONG or TimeZone.SHORTlocale - the locale to useCopyright © 2020. All rights reserved.