本文整理了Java中org.threeten.bp.YearMonth.of()
方法的一些代码示例,展示了YearMonth.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonth.of()
方法的具体详情如下:
包路径:org.threeten.bp.YearMonth
类名称:YearMonth
方法名:of
[英]Obtains an instance of YearMonth from a year and month.
[中]从年和月中获取YearMonth的实例。
代码示例来源:origin: org.threeten/threetenbp
/**
* Combines this year with a month to create a {@code YearMonth}.
* <p>
* This returns a {@code YearMonth} formed from this year and the specified month.
* All possible combinations of year and month are valid.
* <p>
* This method can be used as part of a chain to produce a date:
* <pre>
* LocalDate date = year.atMonth(month).atDay(day);
* </pre>
*
* @param month the month-of-year to use, not null
* @return the year-month formed from this year and the specified month, not null
*/
public YearMonth atMonth(Month month) {
return YearMonth.of(year, month);
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Combines this year with a month to create a {@code YearMonth}.
* <p>
* This returns a {@code YearMonth} formed from this year and the specified month.
* All possible combinations of year and month are valid.
* <p>
* This method can be used as part of a chain to produce a date:
* <pre>
* LocalDate date = year.atMonth(month).atDay(day);
* </pre>
*
* @param month the month-of-year to use, from 1 (January) to 12 (December)
* @return the year-month formed from this year and the specified month, not null
* @throws DateTimeException if the month is invalid
*/
public YearMonth atMonth(int month) {
return YearMonth.of(year, month);
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Combines this year with a month to create a {@code YearMonth}.
* <p>
* This returns a {@code YearMonth} formed from this year and the specified month.
* All possible combinations of year and month are valid.
* <p>
* This method can be used as part of a chain to produce a date:
* <pre>
* LocalDate date = year.atMonth(month).atDay(day);
* </pre>
*
* @param month the month-of-year to use, from 1 (January) to 12 (December)
* @return the year-month formed from this year and the specified month, not null
* @throws DateTimeException if the month is invalid
*/
public YearMonth atMonth(int month) {
return YearMonth.of(year, month);
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Combines this year with a month to create a {@code YearMonth}.
* <p>
* This returns a {@code YearMonth} formed from this year and the specified month.
* All possible combinations of year and month are valid.
* <p>
* This method can be used as part of a chain to produce a date:
* <pre>
* LocalDate date = year.atMonth(month).atDay(day);
* </pre>
*
* @param month the month-of-year to use, not null
* @return the year-month formed from this year and the specified month, not null
*/
public YearMonth atMonth(Month month) {
return YearMonth.of(year, month);
}
代码示例来源:origin: org.threeten/threetenbp
static YearMonth readExternal(DataInput in) throws IOException {
int year = in.readInt();
byte month = in.readByte();
return YearMonth.of(year, month);
}
代码示例来源:origin: ThreeTen/threetenbp
static YearMonth readExternal(DataInput in) throws IOException {
int year = in.readInt();
byte month = in.readByte();
return YearMonth.of(year, month);
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Obtains an instance of {@code YearMonth} from a year and month.
*
* @param year the year to represent, from MIN_YEAR to MAX_YEAR
* @param month the month-of-year to represent, not null
* @return the year-month, not null
* @throws DateTimeException if the year value is invalid
*/
public static YearMonth of(int year, Month month) {
Jdk8Methods.requireNonNull(month, "month");
return of(year, month.getValue());
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Obtains an instance of {@code YearMonth} from a year and month.
*
* @param year the year to represent, from MIN_YEAR to MAX_YEAR
* @param month the month-of-year to represent, not null
* @return the year-month, not null
* @throws DateTimeException if the year value is invalid
*/
public static YearMonth of(int year, Month month) {
Jdk8Methods.requireNonNull(month, "month");
return of(year, month.getValue());
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Obtains the current year-month from the specified clock.
* <p>
* This will query the specified clock to obtain the current year-month.
* Using this method allows the use of an alternate clock for testing.
* The alternate clock may be introduced using {@link Clock dependency injection}.
*
* @param clock the clock to use, not null
* @return the current year-month, not null
*/
public static YearMonth now(Clock clock) {
final LocalDate now = LocalDate.now(clock); // called once
return YearMonth.of(now.getYear(), now.getMonth());
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Obtains the current year-month from the specified clock.
* <p>
* This will query the specified clock to obtain the current year-month.
* Using this method allows the use of an alternate clock for testing.
* The alternate clock may be introduced using {@link Clock dependency injection}.
*
* @param clock the clock to use, not null
* @return the current year-month, not null
*/
public static YearMonth now(Clock clock) {
final LocalDate now = LocalDate.now(clock); // called once
return YearMonth.of(now.getYear(), now.getMonth());
}
代码示例来源:origin: ThreeTen/threetenbp
temporal = LocalDate.from(temporal);
return of(temporal.get(YEAR), temporal.get(MONTH_OF_YEAR));
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain YearMonth from TemporalAccessor: " +
代码示例来源:origin: org.threeten/threetenbp
temporal = LocalDate.from(temporal);
return of(temporal.get(YEAR), temporal.get(MONTH_OF_YEAR));
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain YearMonth from TemporalAccessor: " +
代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp
"Expected array to end.");
return YearMonth.of(year, month);
内容来源于网络,如有侵权,请联系作者删除!