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

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

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

YearMonth.lengthOfMonth介绍

[英]Returns the length of the month, taking account of the year.

This returns the length of the month in days. For example, a date in January would return 31.
[中]返回月份的长度,考虑年份。
这将以天为单位返回月份的长度。例如,1月份的日期将返回31。

代码示例

代码示例来源:origin: stackoverflow.com

  1. YearMonth ym = YearMonth.of(2000, 2);
  2. System.out.println(ym.lengthOfMonth()); //29 as expected

代码示例来源:origin: stackoverflow.com

  1. public static int getNumberofDays(int month,int year)
  2. {
  3. YearMonth yearMonthObject = YearMonth.of(year, month);
  4. return yearMonthObject.lengthOfMonth();
  5. }

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

  1. /**
  2. * Checks if the day-of-month is valid for this year-month.
  3. * <p>
  4. * This method checks whether this year and month and the input day form
  5. * a valid date.
  6. *
  7. * @param dayOfMonth the day-of-month to validate, from 1 to 31, invalid value returns false
  8. * @return true if the day is valid for this year-month
  9. */
  10. public boolean isValidDay(int dayOfMonth) {
  11. return dayOfMonth >= 1 && dayOfMonth <= lengthOfMonth();
  12. }

代码示例来源:origin: stackoverflow.com

  1. YearMonth ym = YearMonth.of( year , month );
  2. int lengthOfMonth = ym.lengthOfMonth();
  3. int dayOfMonth = scan.nextInt();
  4. if( ( dayOfMonth < 1 ) || ( dayOfMonth > ( lengthOfMonth ) ) ) {
  5. report error to user
  6. }

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

  1. /**
  2. * Checks if the day-of-month is valid for this year-month.
  3. * <p>
  4. * This method checks whether this year and month and the input day form
  5. * a valid date.
  6. *
  7. * @param dayOfMonth the day-of-month to validate, from 1 to 31, invalid value returns false
  8. * @return true if the day is valid for this year-month
  9. */
  10. public boolean isValidDay(int dayOfMonth) {
  11. return dayOfMonth >= 1 && dayOfMonth <= lengthOfMonth();
  12. }

代码示例来源:origin: stackoverflow.com

  1. YearMonth ym= YearMonth.of(2015, Month.FEBRUARY);
  2. int monthLen= ym.lengthOfMonth();

代码示例来源:origin: stackoverflow.com

  1. YearMonth ym = YearMonth.from( ld );
  2. int lengthOfMonth = ym.lengthOfMonth();

代码示例来源:origin: stackoverflow.com

  1. public List<LocalDate> getDateRange(YearMonth yearMonth){
  2. List<LocalDate> dateRange = new ArrayList<>();
  3. IntStream.of(yearMonth.lengthOfMonth()).foreach(day -> dateRange.add(yearMonth.at(day));
  4. return dateRange
  5. }

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

  1. /**
  2. * Returns a {@code LocalDate} at the end of the month.
  3. * <p>
  4. * This returns a {@code LocalDate} based on this year-month.
  5. * The day-of-month is set to the last valid day of the month, taking
  6. * into account leap years.
  7. * <p>
  8. * This method can be used as part of a chain to produce a date:
  9. * <pre>
  10. * LocalDate date = year.atMonth(month).atEndOfMonth();
  11. * </pre>
  12. *
  13. * @return the last valid date of this year-month, not null
  14. */
  15. public LocalDate atEndOfMonth() {
  16. return LocalDate.of(year, month, lengthOfMonth());
  17. }

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

  1. /**
  2. * Returns a {@code LocalDate} at the end of the month.
  3. * <p>
  4. * This returns a {@code LocalDate} based on this year-month.
  5. * The day-of-month is set to the last valid day of the month, taking
  6. * into account leap years.
  7. * <p>
  8. * This method can be used as part of a chain to produce a date:
  9. * <pre>
  10. * LocalDate date = year.atMonth(month).atEndOfMonth();
  11. * </pre>
  12. *
  13. * @return the last valid date of this year-month, not null
  14. */
  15. public LocalDate atEndOfMonth() {
  16. return LocalDate.of(year, month, lengthOfMonth());
  17. }

相关文章