📅  最后修改于: 2020-11-14 10:48:04             🧑  作者: Mango
java.time.YearMonth类表示ISO- 8601日历系统中的年月,例如2007-12。
以下是java.time.YearMonth类的声明-
public final class YearMonth
extends Object
implements Temporal, TemporalAdjuster, Comparable, Serializable
Sr.No. | Method & Description |
---|---|
1 | Temporal adjustInto(Temporal temporal)
Adjusts the specified temporal object to have this year-month. |
2 | LocalDate atDay(int dayOfMonth)
Combines this year-month with a day-of-month to create a LocalDate. |
3 | LocalDate atEndOfMonth()
Returns a LocalDate at the end of the month.. |
4 | int compareTo(YearMonth other)
Compares this year-month to another year-month. |
5 | boolean equals(Object otherYearMonth)
Checks if this YearMonth is equal to the specified YearMonth. |
6 | String format(DateTimeFormatter formatter)
Formats this year-month using the specified formatter. |
7 | static YearMonth from(TemporalAmount amount)
Obtains an instance of YearMonth from a temporal amount. |
8 | int get(TemporalField field)
Gets the value of the specified field from this year-month as an int. |
9 | long getLong(TemporalField field)
Gets the value of the requested unit as long. |
10 | Month getMonth()
Gets the month-of-year field using the Month enum. |
11 | int getMonthValue()
Gets the month-of-year field from 1 to 12. |
12 | int getYear()
Gets the year field. |
13 | int hashCode()
A hash code for this YearMonth. |
14 | boolean isAfter(YearMonth other)
Checks if this year-month is after the specified year-month. |
15 | boolean isBefore(YearMonth other)
Checks if this year-month is before the specified year-month. |
16 | boolean isLeapYear()
Checks if the year is a leap year, according to the ISO proleptic calendar system rules. |
17 | boolean isLeap(long year)
Checks if the year is a leap year, according to the ISO proleptic calendar system rules. |
18 | boolean isSupported(TemporalField field)
Checks if the specified field is supported. |
19 | boolean isSupported(TemporalUnit unit)
Checks if the specified unit is supported. |
20 | boolean isValidDay(int dayOfMonth)
Checks if the day-of-month is valid for this year-month. |
21 | int lengthOfMonth()
Returns the length of the month, taking account of the year. |
22 | int lengthOfYear()
Returns the length of the year. |
23 | YearMonth minus(long amountToSubtract, TemporalUnit unit)
Returns a copy of this year with the specified amount subtracted. |
24 | YearMonth minus(TemporalAmount amountToSubtract)
Returns a copy of this YearMonth with the specified YearMonth subtracted. |
25 | YearMonth minusMonths(long monthsToSubtract)
Returns a copy of this YearMonth with the specified month subtracted. |
26 | YearMonth minusYears(long yearsToSubtract)
Returns a copy of this YearMonth with the specified years subtracted. |
27 | static YearMonth now()
Obtains the current year-month from the system clock in the default time-zone. |
28 | static YearMonth now(Clock clock)
Obtains the current year-month from the specified clock. |
29 | static YearMonth now(ZoneId zone)
Obtains the current year-month from the system clock in the specified time-zone. |
30 | static YearMonth of(int years, int month)
Obtains an instance of YearMonth from a year and month. |
31 | static YearMonth of(int years, Month month)
Obtains an instance of YearMonth from a year and month. |
32 | static YearMonth parse(CharSequence text)
Obtains a YearMonth from a text string such as 2007-12. |
33 | static YearMonth parse(CharSequence text, DateTimeFormatter formatter)
Obtains an instance of YearMonth from a text string using a specific formatter. |
34 | YearMonth plus(long amountToAdd, TemporalUnit unit)
Returns a copy of this YearMonth with the specified YearMonth added. |
35 | YearMonth plus(TemporalAmount amountToAdd)
Returns a copy of this YearMonth with the specified YearMonth added. |
36 | YearMonth plusMonths(long monthsToAdd)
Returns a copy of this YearMonth with the specified months added. |
37 | YearMonth plusYears(long yearsToAdd)
Returns a copy of this YearMonth with the specified years added. |
38 | Queries this year-month using the specified query. |
39 | ValueRange range(TemporalField field)
Gets the range of valid values for the specified field. |
40 | String toString()
Outputs this year-month as a String. |
41 | long until(Temporal endExclusive, TemporalUnit unit)
Calculates the amount of time until another year-month in terms of the specified unit. |
42 | YearMonth with(TemporalAdjuster adjuster)
Returns an adjusted copy of this year-month. |
43 | YearMonth with(TemporalField field, long newValue)
Returns a copy of this year-month with the specified field set to a new value. |
44 | YearMonth withMonth(int month)
Returns a copy of this YearMonth with the month-of-year altered. |
45 | YearMonth withYear(int year)
Returns a copy of this YearMonth with the year altered. |
此类从以下类继承方法-