Class FastDatePrinter
java.lang.Object
org.miaixz.bus.core.center.date.printer.SimpleDatePrinter
org.miaixz.bus.core.center.date.printer.FastDatePrinter
- All Implemented Interfaces:
Serializable,DatePrinter,FormatPrinter
SimpleDateFormat 的线程安全版本,用于将 Date 格式化输出
Thanks to Apache Commons Lang 3.5- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInner class defining a numeric rule.static interface规则 -
Field Summary
Fields inherited from class org.miaixz.bus.core.center.date.printer.SimpleDatePrinter
locale, pattern, timeZone -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformat(long millis) 格式化日期表示的毫秒数<B extends Appendable>
Bformat(long millis, B buf) Formats a millisecondlongvalue into the suppliedAppendable.Formats aDate,CalendarorLong(milliseconds) object.Formats aCalendarobject.<B extends Appendable>
BFormats aCalendarobject into the suppliedAppendable.使用GregorianCalendar格式化Date<B extends Appendable>
BFormats aDateobject into the suppliedAppendableusing aGregorianCalendar.int估算生成的日期字符串长度 实际生成的字符串长度小于或等于此值protected List<FastDatePrinter.Rule> Returns a list of Rules given a pattern.protected StringparseToken(String pattern, int[] indexRef) Performs the parsing of tokens.protected FastDatePrinter.NumberRuleselectNumberRule(int field, int padding) Gets an appropriate rule for the padding required.Methods inherited from class org.miaixz.bus.core.center.date.printer.SimpleDatePrinter
equals, getLocale, getPattern, getTimeZone, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.miaixz.bus.core.center.date.printer.DatePrinter
getLocale, getPattern, getTimeZone
-
Constructor Details
-
FastDatePrinter
构造,内部使用- Parameters:
pattern- 使用SimpleDateFormat相同的日期格式timeZone- 非空时区TimeZonelocale- 非空Locale日期地理位置
-
-
Method Details
-
parsePattern
Returns a list of Rules given a pattern.- Returns:
- a
Listof Rule objects - Throws:
IllegalArgumentException- if pattern is invalid
-
parseToken
Performs the parsing of tokens.- Parameters:
pattern- the patternindexRef- index references- Returns:
- parsed token
-
selectNumberRule
Gets an appropriate rule for the padding required.- Parameters:
field- the field to get a rule forpadding- the padding required- Returns:
- a new rule with the correct padding
-
format
Formats aDate,CalendarorLong(milliseconds) object.- Parameters:
obj- the object to format- Returns:
- The formatted value.
-
format
Description copied from interface:FormatPrinter格式化日期表示的毫秒数- Specified by:
formatin interfaceFormatPrinter- Parameters:
millis- 日期毫秒数- Returns:
- the formatted string
-
format
Description copied from interface:FormatPrinter使用GregorianCalendar格式化Date- Specified by:
formatin interfaceFormatPrinter- Parameters:
date- 日期Date- Returns:
- 格式化后的字符串
-
format
Description copied from interface:FormatPrinterFormats aCalendarobject.格式化
Calendar- Specified by:
formatin interfaceFormatPrinter- Parameters:
calendar-Calendar- Returns:
- 格式化后的字符串
-
format
Description copied from interface:FormatPrinterFormats a millisecondlongvalue into the suppliedAppendable.- Specified by:
formatin interfaceFormatPrinter- Type Parameters:
B- the Appendable class type, usually StringBuilder or StringBuffer.- Parameters:
millis- the millisecond value to formatbuf- the buffer to format into- Returns:
- the specified string buffer
-
format
Description copied from interface:FormatPrinterFormats aDateobject into the suppliedAppendableusing aGregorianCalendar.- Specified by:
formatin interfaceFormatPrinter- Type Parameters:
B- the Appendable class type, usually StringBuilder or StringBuffer.- Parameters:
date- the date to formatbuf- the buffer to format into- Returns:
- the specified string buffer
-
format
Description copied from interface:FormatPrinterFormats aCalendarobject into the suppliedAppendable. The TimeZone set on the Calendar is only used to adjust the time offset. The TimeZone specified during the construction of the Parser will determine the TimeZone used in the formatted string.- Specified by:
formatin interfaceFormatPrinter- Type Parameters:
B- the Appendable class type, usually StringBuilder or StringBuffer.- Parameters:
calendar- the calendar to formatbuf- the buffer to format into- Returns:
- the specified string buffer
-
getMaxLengthEstimate
public int getMaxLengthEstimate()估算生成的日期字符串长度 实际生成的字符串长度小于或等于此值- Returns:
- 日期字符串长度
-