java.time.YearMonth类

简介

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

类声明

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

 
公共最终类YearMonth 
 extends Object 
实现Temporal,TemporalAdjuster,Comparable< YearMonth>,Serializable

类方法

Sr.No .方法&说明
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)

从a获取YearMonth的实例时间金额.

8int get(TemporalField field)

以int为单位从此年份获取指定字段的值.

9long getLong(TemporalField field)

获取所请求单位的值.

10Month getMonth()

获取月份使用月枚举的字段.

11int getMonthValue()

获取1到12之间的年份字段./p>

12int getYear()

获取年份字段.

13int hashCode()

thi的哈希码s YearMonth.

14boolean isAfter(YearMonth other)

检查此年月是否在指定的年月之后.

15boolean isBefore(YearMonth other)

检查此年月是否在指定的年月之前.

16boolean isLeapYear()

根据ISO符号日历系统规则检查年份是否为闰年.

17boolean isLeap(long year)

根据IS,检查年份是否为闰年O proleptic日历系统规则.

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的副本以及指定减去d个月.

26YearMonth minusYears(long yearsToSubtract)

返回此YearMonth的副本,并减去指定的年份.

27static YearMonth now()

从默认时区的系统时钟获得当前年月.

28static YearMonth now(Clock clock)

从指定时钟获得当前年月.

29static YearMonth now(ZoneId zone)

从sys获取当前年月在指定时区内的时钟.

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)

Obt使用特定格式化程序从文本字符串中查看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的副本,并添加指定的年份.

38<R> R query(TemporalQuery<R> query)

使用指定的查询查询今年 - 月.

39ValueRange range(TemporalField field) )

获取指定字段的有效值范围.

40String toString()

将此年份作为字符串输出.

41long until(Temporal endExclusive, TemporalUnit unit)

计算金额按指定单位计算的直到另一年 - 月的时间.

42YearMonth with(TemporalA) djuster adjuster)

返回本年度的调整副本.

43YearMonth with(TemporalField field,long newValue)

返回此年月的副本,并将指定字段设置为新值.

44YearMonth withMonth(int month)

返回此YearMonth的副本,其中年份已更改.

45YearMonth withYear(int year)

返回此YearMonth的副本,其中年份已更改.

继承的方法

此类继承以下类中的方法 :

  • Java.lang.Object