目录

java.time - YearMonth

介绍 (Introduction)

java.time.YearMonth类表示ISO- java.time.YearMonth ,例如2007-12。

类声明

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

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

类方法

Sr.No. 方法和描述
1 Temporal adjustInto(Temporal temporal)

调整指定的时间对象以具有此年 - 月。

2 LocalDate atDay(int dayOfMonth)

将今年和月份结合起来创建LocalDate。

3 LocalDate atEndOfMonth()

返回月末的LocalDate ..

4 int compareTo(YearMonth other)

比较今年和另一个月。

5 boolean equals(Object otherYearMonth)

检查此YearMonth是否等于指定的YearMonth。

6 String format(DateTimeFormatter formatter)

使用指定的格式化程序格式化今年 - 月。

7 static YearMonth from(TemporalAmount amount)

从时间量获得YearMonth的实例。

8 int get(TemporalField field)

获取此年份中指定字段的值作为int。

9 long getLong(TemporalField field)

获取所请求单位的值。

10 Month getMonth()

使用Month枚举获取月份字段。

11 int getMonthValue()

获取1到12之间的月份字段。

12 int getYear()

获取年份字段。

13 int hashCode()

此YearMonth的哈希码。

14 boolean isAfter(YearMonth other)

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

15 boolean isBefore(YearMonth other)

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

16 boolean isLeapYear()

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

17 boolean isLeap(long year)

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

18 boolean isSupported(TemporalField field)

检查是否支持指定的字段。

19 boolean isSupported(TemporalUnit unit)

检查指定的单元是否受支持。

20 boolean isValidDay(int dayOfMonth)

检查每月的日期是否有效。

21 int lengthOfMonth()

考虑到年份,返回月份的长度。

22 int lengthOfYear()

返回年份的长度。

23 YearMonth minus(long amountToSubtract, TemporalUnit unit)

返回今年的副本,减去指定的金额。

24 YearMonth minus(TemporalAmount amountToSubtract)

返回此YearMonth的副本,并减去指定的YearMonth。

25 YearMonth minusMonths(long monthsToSubtract)

返回此YearMonth的副本,并减去指定的月份。

26 YearMonth minusYears(long yearsToSubtract)

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

27 static YearMonth now()

从默认时区中的系统时钟获取当前年月。

28 static YearMonth now(Clock clock)

从指定的时钟获得当前年月。

29 static YearMonth now(ZoneId zone)

从指定时区的系统时钟获取当前年月。

30 static YearMonth of(int years, int month)

从一年和一月获得YearMonth的实例。

31 static YearMonth of(int years, Month month)

从一年和一月获得YearMonth的实例。

32 static YearMonth parse(CharSequence text)

从文本字符串(例如2007-12)获取YearMonth。

33 static YearMonth parse(CharSequence text, DateTimeFormatter formatter)

使用特定格式化程序从文本字符串中获取YearMonth的实例。

34 YearMonth plus(long amountToAdd, TemporalUnit unit)

返回此YearMonth的副本,并添加指定的YearMonth。

35 YearMonth plus(TemporalAmount amountToAdd)

返回此YearMonth的副本,并添加指定的YearMonth。

36 YearMonth plusMonths(long monthsToAdd)

返回此YearMonth的副本,并添加指定的月份。

37 YearMonth plusYears(long yearsToAdd)

返回此YearMonth的副本,并添加指定的年份。

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

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

39 ValueRange range(TemporalField field)

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

40 String toString()

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

41 long until(Temporal endExclusive, TemporalUnit unit)

根据指定的单位计算直到另一年 - 月的时间量。

42 YearMonth with(TemporalAdjuster adjuster)

返回此年度的调整副本。

43 YearMonth with(TemporalField field, long newValue)

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

44 YearMonth withMonth(int month)

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

45 YearMonth withYear(int year)

返回此YearMonth的副本,并更改​​年份。

方法继承

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

  • Java.lang.Object
↑回到顶部↑
WIKI教程 @2018