java.lang.Object
org.miaixz.bus.core.center.date.format.DatePattern
日期格式表达式类,用于解析和格式化日期时间。
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface数字格式化规则接口。static interface日期格式化规则接口。 -
Constructor Summary
ConstructorsConstructorDescriptionDatePattern(String patternStr, Locale locale, TimeZone timeZone) 构造函数,初始化日期格式表达式。 -
Method Summary
Modifier and TypeMethodDescription<B extends Appendable>
BapplyRules(Calendar calendar, B buf) 根据指定格式,将日期时间格式化到输出缓冲区。int获取估算的格式化后字符串长度。protected static StringparseToken(String pattern, int[] indexRef) 解析日期格式表达式中的标记。protected static DatePattern.NumberRuleselectNumberRule(int field, int padding) 根据字段和填充长度选择合适的数字规则。
-
Constructor Details
-
DatePattern
构造函数,初始化日期格式表达式。- Parameters:
patternStr- 日期表达式字符串locale- 地域信息timeZone- 时区
-
-
Method Details
-
parseToken
解析日期格式表达式中的标记。- Parameters:
pattern- 格式表达式字符串indexRef- 索引引用数组- Returns:
- 解析出的标记
-
selectNumberRule
根据字段和填充长度选择合适的数字规则。- Parameters:
field- 日期字段padding- 填充长度- Returns:
- 数字规则
-
getEstimateLength
public int getEstimateLength()获取估算的格式化后字符串长度。- Returns:
- 估算长度
-
applyRules
根据指定格式,将日期时间格式化到输出缓冲区。- Type Parameters:
B- Appendable实现类(如StringBuilder或StringBuffer)- Parameters:
calendar- 日历对象buf- 输出缓冲区- Returns:
- 格式化后的Appendable对象
- Throws:
DateException- 如果发生I/O错误
-