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 格式化为字符串。 参考 Apache Commons Lang 3.5。- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class org.miaixz.bus.core.center.date.printer.SimpleDatePrinter
locale, pattern, timeZone -
Constructor Summary
ConstructorsConstructorDescriptionFastDatePrinter(String pattern, TimeZone timeZone, Locale locale) 构造方法,初始化日期格式化器。 -
Method Summary
Modifier and TypeMethodDescriptionformat(long millis) 格式化毫秒时间戳为字符串。<B extends Appendable>
Bformat(long millis, B buf) 格式化毫秒时间戳到指定缓冲区。格式化日历对象为字符串。<B extends Appendable>
B格式化日历对象到指定缓冲区。格式化日期对象为字符串。<B extends Appendable>
B格式化日期对象到指定缓冲区。int估算格式化后的日期字符串最大长度。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- 非空时区对象locale- 非空地域对象
-
-
Method Details
-
format
- Parameters:
obj- 要格式化的对象- Returns:
- 格式化后的字符串
- Throws:
IllegalArgumentException- 如果对象类型不支持
-
format
格式化日期对象为字符串。- Specified by:
formatin interfaceFormatPrinter- Parameters:
date- 日期对象- Returns:
- 格式化后的字符串
-
format
格式化毫秒时间戳为字符串。- Specified by:
formatin interfaceFormatPrinter- Parameters:
millis- 毫秒时间戳- Returns:
- 格式化后的字符串
-
format
格式化日历对象为字符串。- Specified by:
formatin interfaceFormatPrinter- Parameters:
calendar- 日历对象- Returns:
- 格式化后的字符串
-
format
格式化日期对象到指定缓冲区。- Specified by:
formatin interfaceFormatPrinter- Type Parameters:
B- Appendable 类型- Parameters:
date- 日期对象buf- 输出缓冲区- Returns:
- 格式化后的缓冲区
-
format
格式化毫秒时间戳到指定缓冲区。- Specified by:
formatin interfaceFormatPrinter- Type Parameters:
B- Appendable 类型- Parameters:
millis- 毫秒时间戳buf- 输出缓冲区- Returns:
- 格式化后的缓冲区
-
format
格式化日历对象到指定缓冲区。- Specified by:
formatin interfaceFormatPrinter- Type Parameters:
B- Appendable 类型- Parameters:
calendar- 日历对象buf- 输出缓冲区- Returns:
- 格式化后的缓冲区
-
getMaxLengthEstimate
public int getMaxLengthEstimate()估算格式化后的日期字符串最大长度。- Returns:
- 最大长度估算值
-