Class DateAdapter

java.lang.Object
cloud.opencode.base.xml.bind.adapter.DateAdapter

public final class DateAdapter extends Object
Date Adapter - Adapters for date/time types 日期适配器 - 日期/时间类型的适配器

This class provides XML adapters for common date/time types.

此类为常见的日期/时间类型提供 XML 适配器。

Features | 主要功能:

  • LocalDate, LocalDateTime, LocalTime adapters - LocalDate、LocalDateTime、LocalTime 适配器
  • Instant and ZonedDateTime adapters - Instant 和 ZonedDateTime 适配器
  • Legacy java.util.Date adapter - 传统 java.util.Date 适配器
  • Duration and Period adapters - Duration 和 Period 适配器
  • Customizable DateTimeFormatter support - 可自定义 DateTimeFormatter 支持

Usage Examples | 使用示例:

// Register a date adapter with the binder
XmlBinder binder = XmlBinder.create()
    .registerAdapter(new DateAdapter.LocalDateAdapter());

// With custom format
XmlBinder binder = XmlBinder.create()
    .registerAdapter(new DateAdapter.LocalDateAdapter(
        DateTimeFormatter.ofPattern("dd/MM/yyyy")));

Security | 安全性:

  • Thread-safe: Yes (adapters are stateless or use immutable formatters) - 线程安全: 是(适配器无状态或使用不可变格式化器)
  • Null-safe: Yes (null inputs return null) - 空值安全: 是(空值输入返回 null)
Since:
JDK 25, opencode-base-xml V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also: