Class Weeks

java.lang.Object
cloud.opencode.base.date.extra.Weeks
All Implemented Interfaces:
Serializable, Comparable<Weeks>, TemporalAmount

public final class Weeks extends Object implements TemporalAmount, Comparable<Weeks>, Serializable
Weeks unit class representing a number of weeks 周数单位类,表示周数

This class represents a number of weeks. It implements TemporalAmount for use with java.time.

此类表示周数。实现TemporalAmount以与java.time配合使用。

Features | 主要功能:

  • Type-safe weeks representation - 类型安全的周数表示
  • Arithmetic operations (plus, minus, multiply, divide) - 算术操作(加、减、乘、除)
  • Conversion to Period, Days - 转换为Period、Days
  • TemporalAmount implementation for java.time integration - 实现TemporalAmount以集成java.time

Usage Examples | 使用示例:

Weeks w = Weeks.of(4);
Days d = w.toDays();  // 28 days
LocalDate date = LocalDate.now().plus(w);

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
  • Overflow-safe: Yes (uses Math.addExact/multiplyExact) - 溢出安全: 是(使用Math.addExact/multiplyExact)
Since:
JDK 25, opencode-base-date V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also: