gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-17 13:11:31 29 4
gpt4 key购买 nike

本文整理了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

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

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

public static int getNumberofDays(int month,int year)
{
  YearMonth yearMonthObject = YearMonth.of(year, month); 
  return yearMonthObject.lengthOfMonth();
}

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

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

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

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

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

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

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

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

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

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

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

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

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

/**
 * Returns a {@code LocalDate} at the end of the month.
 * <p>
 * This returns a {@code LocalDate} based on this year-month.
 * The day-of-month is set to the last valid day of the month, taking
 * into account leap years.
 * <p>
 * This method can be used as part of a chain to produce a date:
 * <pre>
 *  LocalDate date = year.atMonth(month).atEndOfMonth();
 * </pre>
 *
 * @return the last valid date of this year-month, not null
 */
public LocalDate atEndOfMonth() {
  return LocalDate.of(year, month, lengthOfMonth());
}

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

/**
 * Returns a {@code LocalDate} at the end of the month.
 * <p>
 * This returns a {@code LocalDate} based on this year-month.
 * The day-of-month is set to the last valid day of the month, taking
 * into account leap years.
 * <p>
 * This method can be used as part of a chain to produce a date:
 * <pre>
 *  LocalDate date = year.atMonth(month).atEndOfMonth();
 * </pre>
 *
 * @return the last valid date of this year-month, not null
 */
public LocalDate atEndOfMonth() {
  return LocalDate.of(year, month, lengthOfMonth());
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com