手册
目录
收藏770
分享
阅读811
更新时间2025-07-22
前言:
在本教程中,您将学习如何使用java.time.MonthDay类,简介java.time.MonthDay类表示ISO-8601日历系统中的月日,例如--12-03。
java.time.MonthDay 类表示 ISO-8601 日历系统中的月日,例如 --12-03。
以下是 java.time.MonthDay 类的声明 −
public final class MonthDay
extends Object
implements TemporalAccessor, TemporalAdjuster, Comparable, Serializable
点击 "运行实例" 按钮查看在线实例
| 序号 | 方法 & 描述 |
|---|---|
| 1 | Temporal adjustInto(Temporal temporal)
将指定的时间对象调整为具有此月-日。 |
| 2 | LocalDate atYear(int year)
结合这个月-日和一年来创建一个 LocalDate。 |
| 3 | int compareTo(MonthDay other)
将此月日与另一个月日进行比较。 |
| 4 | boolean equals(Object obj)
检查这个月日是否等于另一个月日。 |
| 5 | String format(DateTimeFormatter formatter)
使用指定的格式化程序格式化这个月-日。 |
| 6 | static MonthDay from(TemporalAccessor temporal)
从时间对象中获取 MonthDay 的实例。 |
| 7 | int get(TemporalField field)
以 int 形式获取本月-日中指定字段的值。 |
| 8 | int getDayOfMonth()
获取日期字段。 |
| 9 | long getLong(TemporalField field)
以long形式从此时获取指定字段的值。 |
| 10 | Month getMonth()
使用 Month 枚举获取月份字段。 |
| 11 | int getMonthValue()
获取从 1 到 12 的年份字段。 |
| 12 | int hashCode()
这个月日的哈希码。 |
| 13 | boolean isAfter(MonthDay other)
检查这个月日是否在指定的月日之后。 |
| 14 | boolean isBefore(MonthDay other)
检查这个月日是否在指定的月日之前。 |
| 15 | boolean isSupported(TemporalField field)
检查是否支持指定的字段。 |
| 16 | boolean isSupported(TemporalUnit unit)
检查是否支持指定的单位。 |
| 17 | boolean isValidYear(int year)
检查年份是否适用于本月日。 |
| 18 | static MonthDay now()
从默认时区的系统时钟获取当前时间。 |
| 19 | static MonthDay now(Clock clock)
从指定时钟获取当前时间。 |
| 20 | static MonthDay now(ZoneId zone)
从指定时区的系统时钟获取当前时间。 |
| 21 | static MonthDay of(int month, int dayOfMonth)
获取 MonthDay 的实例。 |
| 22 | static MonthDay of(Month month, int dayOfMonth)
获取 MonthDay 的实例。 |
| 23 | static MonthDay parse(CharSequence text)
从 --12-03 等文本字符串中获取 MonthDay 的实例。 |
| 24 | static MonthDay parse(CharSequence text, DateTimeFormatter formatter)
使用特定格式化程序从文本字符串中获取 MonthDay 的实例。 |
| 25 | 这次使用指定的查询进行查询。 |
| 26 | ValueRange range(TemporalField field)
获取指定字段的有效值范围。 |
| 27 | String toString()
将此日期输出为字符串,例如 --12-03。 |
| 28 | MonthDay with(Month month)
返回此 MonthDay 的副本,其中更改了年份。 |
| 29 | MonthDay withDayOfMonth(int dayOfMonth)
返回此 MonthDay 的副本,其中日期已更改。 |
| 30 | MonthDay withMonth(int month)
返回此 MonthDay 的副本,其中更改了年份。 |
这个类继承了以下类的方法 −
相关
视频
RELATED VIDEOS
科技资讯
1
2
3
4
5
6
7
8
9
精选课程
共5课时
17.2万人学习
共49课时
77万人学习
共29课时
61.7万人学习
共25课时
39.3万人学习
共43课时
70.9万人学习
共25课时
61.6万人学习
共22课时
23万人学习
共28课时
33.9万人学习
共89课时
125万人学习