org.threeten.bp.YearMonth.of()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(242)

本文整理了Java中org.threeten.bp.YearMonth.of()方法的一些代码示例,展示了YearMonth.of()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonth.of()方法的具体详情如下:
包路径:org.threeten.bp.YearMonth
类名称:YearMonth
方法名:of

YearMonth.of介绍

[英]Obtains an instance of YearMonth from a year and month.
[中]从年和月中获取YearMonth的实例。

代码示例

代码示例来源:origin: org.threeten/threetenbp

  1. /**
  2. * Combines this year with a month to create a {@code YearMonth}.
  3. * <p>
  4. * This returns a {@code YearMonth} formed from this year and the specified month.
  5. * All possible combinations of year and month are valid.
  6. * <p>
  7. * This method can be used as part of a chain to produce a date:
  8. * <pre>
  9. * LocalDate date = year.atMonth(month).atDay(day);
  10. * </pre>
  11. *
  12. * @param month the month-of-year to use, not null
  13. * @return the year-month formed from this year and the specified month, not null
  14. */
  15. public YearMonth atMonth(Month month) {
  16. return YearMonth.of(year, month);
  17. }

代码示例来源:origin: ThreeTen/threetenbp

  1. /**
  2. * Combines this year with a month to create a {@code YearMonth}.
  3. * <p>
  4. * This returns a {@code YearMonth} formed from this year and the specified month.
  5. * All possible combinations of year and month are valid.
  6. * <p>
  7. * This method can be used as part of a chain to produce a date:
  8. * <pre>
  9. * LocalDate date = year.atMonth(month).atDay(day);
  10. * </pre>
  11. *
  12. * @param month the month-of-year to use, from 1 (January) to 12 (December)
  13. * @return the year-month formed from this year and the specified month, not null
  14. * @throws DateTimeException if the month is invalid
  15. */
  16. public YearMonth atMonth(int month) {
  17. return YearMonth.of(year, month);
  18. }

代码示例来源:origin: org.threeten/threetenbp

  1. /**
  2. * Combines this year with a month to create a {@code YearMonth}.
  3. * <p>
  4. * This returns a {@code YearMonth} formed from this year and the specified month.
  5. * All possible combinations of year and month are valid.
  6. * <p>
  7. * This method can be used as part of a chain to produce a date:
  8. * <pre>
  9. * LocalDate date = year.atMonth(month).atDay(day);
  10. * </pre>
  11. *
  12. * @param month the month-of-year to use, from 1 (January) to 12 (December)
  13. * @return the year-month formed from this year and the specified month, not null
  14. * @throws DateTimeException if the month is invalid
  15. */
  16. public YearMonth atMonth(int month) {
  17. return YearMonth.of(year, month);
  18. }

代码示例来源:origin: ThreeTen/threetenbp

  1. /**
  2. * Combines this year with a month to create a {@code YearMonth}.
  3. * <p>
  4. * This returns a {@code YearMonth} formed from this year and the specified month.
  5. * All possible combinations of year and month are valid.
  6. * <p>
  7. * This method can be used as part of a chain to produce a date:
  8. * <pre>
  9. * LocalDate date = year.atMonth(month).atDay(day);
  10. * </pre>
  11. *
  12. * @param month the month-of-year to use, not null
  13. * @return the year-month formed from this year and the specified month, not null
  14. */
  15. public YearMonth atMonth(Month month) {
  16. return YearMonth.of(year, month);
  17. }

代码示例来源:origin: org.threeten/threetenbp

  1. static YearMonth readExternal(DataInput in) throws IOException {
  2. int year = in.readInt();
  3. byte month = in.readByte();
  4. return YearMonth.of(year, month);
  5. }

代码示例来源:origin: ThreeTen/threetenbp

  1. static YearMonth readExternal(DataInput in) throws IOException {
  2. int year = in.readInt();
  3. byte month = in.readByte();
  4. return YearMonth.of(year, month);
  5. }

代码示例来源:origin: ThreeTen/threetenbp

  1. /**
  2. * Obtains an instance of {@code YearMonth} from a year and month.
  3. *
  4. * @param year the year to represent, from MIN_YEAR to MAX_YEAR
  5. * @param month the month-of-year to represent, not null
  6. * @return the year-month, not null
  7. * @throws DateTimeException if the year value is invalid
  8. */
  9. public static YearMonth of(int year, Month month) {
  10. Jdk8Methods.requireNonNull(month, "month");
  11. return of(year, month.getValue());
  12. }

代码示例来源:origin: org.threeten/threetenbp

  1. /**
  2. * Obtains an instance of {@code YearMonth} from a year and month.
  3. *
  4. * @param year the year to represent, from MIN_YEAR to MAX_YEAR
  5. * @param month the month-of-year to represent, not null
  6. * @return the year-month, not null
  7. * @throws DateTimeException if the year value is invalid
  8. */
  9. public static YearMonth of(int year, Month month) {
  10. Jdk8Methods.requireNonNull(month, "month");
  11. return of(year, month.getValue());
  12. }

代码示例来源:origin: org.threeten/threetenbp

  1. /**
  2. * Obtains the current year-month from the specified clock.
  3. * <p>
  4. * This will query the specified clock to obtain the current year-month.
  5. * Using this method allows the use of an alternate clock for testing.
  6. * The alternate clock may be introduced using {@link Clock dependency injection}.
  7. *
  8. * @param clock the clock to use, not null
  9. * @return the current year-month, not null
  10. */
  11. public static YearMonth now(Clock clock) {
  12. final LocalDate now = LocalDate.now(clock); // called once
  13. return YearMonth.of(now.getYear(), now.getMonth());
  14. }

代码示例来源:origin: ThreeTen/threetenbp

  1. /**
  2. * Obtains the current year-month from the specified clock.
  3. * <p>
  4. * This will query the specified clock to obtain the current year-month.
  5. * Using this method allows the use of an alternate clock for testing.
  6. * The alternate clock may be introduced using {@link Clock dependency injection}.
  7. *
  8. * @param clock the clock to use, not null
  9. * @return the current year-month, not null
  10. */
  11. public static YearMonth now(Clock clock) {
  12. final LocalDate now = LocalDate.now(clock); // called once
  13. return YearMonth.of(now.getYear(), now.getMonth());
  14. }

代码示例来源:origin: ThreeTen/threetenbp

  1. temporal = LocalDate.from(temporal);
  2. return of(temporal.get(YEAR), temporal.get(MONTH_OF_YEAR));
  3. } catch (DateTimeException ex) {
  4. throw new DateTimeException("Unable to obtain YearMonth from TemporalAccessor: " +

代码示例来源:origin: org.threeten/threetenbp

  1. temporal = LocalDate.from(temporal);
  2. return of(temporal.get(YEAR), temporal.get(MONTH_OF_YEAR));
  3. } catch (DateTimeException ex) {
  4. throw new DateTimeException("Unable to obtain YearMonth from TemporalAccessor: " +

代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp

  1. "Expected array to end.");
  2. return YearMonth.of(year, month);

相关文章