Class CustomFormat
java.lang.Object
org.miaixz.bus.core.center.date.format.CustomFormat
全局自定义格式
用于定义用户指定的日期格式和输出日期的关系
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringformat(TemporalAccessor temporalAccessor, CharSequence format) 使用自定义格式格式化日期static Stringformat(Date date, CharSequence format) 使用自定义格式格式化日期static booleanisCustomFormat(String format) 检查指定格式是否为自定义格式static Dateparse(CharSequence dateStr, String format) 使用自定义格式解析日期static voidputFormatter(String format, Function<Date, String> func) 加入日期格式化规则static voidputParser(String format, Function<CharSequence, Date> func) 加入日期解析规则
-
Field Details
-
FORMAT_SECONDS
格式:秒时间戳(Unix时间戳)- See Also:
-
FORMAT_MILLISECONDS
格式:毫秒时间戳- See Also:
-
-
Constructor Details
-
CustomFormat
public CustomFormat()
-
-
Method Details
-
putFormatter
加入日期格式化规则- Parameters:
format- 格式func- 格式化函数
-
putParser
加入日期解析规则- Parameters:
format- 格式func- 解析函数
-
isCustomFormat
检查指定格式是否为自定义格式- Parameters:
format- 格式- Returns:
- 是否为自定义格式
-
format
使用自定义格式格式化日期- Parameters:
date- 日期format- 自定义格式- Returns:
- 格式化后的日期
-
format
使用自定义格式格式化日期- Parameters:
temporalAccessor- 日期format- 自定义格式- Returns:
- 格式化后的日期
-
parse
使用自定义格式解析日期- Parameters:
dateStr- 日期字符串format- 自定义格式- Returns:
- 格式化后的日期
-