java.time.YearMonth类

java.time.YearMonth类表示ISO-8601日历系统中的年月,例如2007-12

类声明

以下是java.time.YearMonth类的声明 -

public final class YearMonth
   extends Object
      implements Temporal, TemporalAdjuster, Comparable<YearMonth>,Serializable

Java

类方法

编号方法描述
1Temporal adjustInto(Temporal temporal)调整指定的时间对象以具有此年-月
2LocalDate atDay(int dayOfMonth)将此年份和月份结合起来创建LocalDate
3LocalDate atEndOfMonth()返回月末的LocalDate
4int compareTo(YearMonth other)此年月和另一个年月相比较。
5boolean equals(Object otherYearMonth)检查此YearMonth是否等于指定的YearMonth
6String format(DateTimeFormatter formatter)使用指定的格式化程序格式化此年月。
7static YearMonth from(TemporalAmount amount)从时间量获得YearMonth的实例。
8int get(TemporalField field)获取此年份中指定字段的int值。
9long getLong(TemporalField field)获取所请求单位的值。
10Month getMonth()使用Month枚举获取月份字段。
11int getMonthValue()获取月份字段112之间的值。
12int getYear()获取年份字段的值。
13int hashCode()YearMonth的哈希码。
14boolean isAfter(YearMonth other)检查此年月是否在指定的年月之后。
15boolean isBefore(YearMonth other)检查此年月是否在指定的年月之前。
16boolean isLeapYear()根据ISO符号日历系统规则,检查年份是否为闰年。
17boolean isLeap(long year)根据ISO符号日历系统规则,检查年份是否为闰年。
18boolean isSupported(TemporalField field)检查是否支持指定的字段。
19boolean isSupported(TemporalUnit unit)检查指定的单元是否受支持。
20boolean isValidDay(int dayOfMonth)检查每月的日期是否有效。
21int lengthOfMonth()返回月份的长度。
22int lengthOfYear()返回年份的长度。
23YearMonth minus(long amountToSubtract, TemporalUnit unit)返回此年份的副本,减去指定的金额。
24YearMonth minus(TemporalAmount amountToSubtract)返回此YearMonth的副本,并减去指定的YearMonth
25YearMonth minusMonths(long monthsToSubtract)返回此YearMonth的副本,并减去指定的月份。
26YearMonth minusYears(long yearsToSubtract)返回此YearMonth的副本,并减去指定的年份。
27static YearMonth now()从默认时区中的系统时钟获取当前年月。
28static YearMonth now(Clock clock)从指定的时钟获得当前年月。
29static YearMonth now(ZoneId zone)从指定时区的系统时钟获取当前年月。
30static YearMonth of(int years, int month)从指定年份和月份获得YearMonth的实例。
31static YearMonth of(int years, Month month)从指定年份和月份获得YearMonth的实例。
32static YearMonth parse(CharSequence text)从文本字符串(例如2007-12)获取YearMonth
33static YearMonth parse(CharSequence text, DateTimeFormatter formatter)使用特定格式化程序从文本字符串中获取YearMonth的实例。
34YearMonth plus(long amountToAdd, TemporalUnit unit)返回此YearMonth的副本,并添加指定的YearMonth
35YearMonth plus(TemporalAmount amountToAdd)返回此YearMonth的副本,并添加指定的YearMonth
36YearMonth plusMonths(long monthsToAdd)返回此YearMonth的副本,并添加指定的月份。
37YearMonth plusYears(long yearsToAdd)返回此YearMonth的副本,并添加指定的年份。
38R query(TemporalQuery query)使用指定的查询来查询此年月。
39ValueRange range(TemporalField field)获取指定字段的有效值范围。
40String toString()将此年份作为字符串输出。
41long until(Temporal endExclusive, TemporalUnit unit)根据指定的单位计算直到另一年月的时间量。
42YearMonth with(TemporalAdjuster adjuster)返回此年份的调整副本。
43YearMonth with(TemporalField field, long newValue)返回此年月的副本,并将指定的字段设置为新值。
44YearMonth withMonth(int month)返回此YearMonth的副本,其中年份已更改。
45YearMonth withYear(int year)返回此YearMonth的副本,并更改年份。

方法继承

该类继承以下类中的方法 -

  • Java.lang.Object

  • 15
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

智慧浩海

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值