gpt4 book ai didi

java.time.YearMonth.isLeapYear()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 00:20:40 27 4
gpt4 key购买 nike

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

YearMonth.isLeapYear介绍

[英]Checks if the year is a leap year, according to the ISO proleptic calendar system rules.

This method applies the current rules for leap years across the whole time-line. In general, a year is a leap year if it is divisible by four without remainder. However, years divisible by 100, are not leap years, with the exception of years divisible by 400 which are.

For example, 1904 is a leap year it is divisible by 4. 1900 was not a leap year as it is divisible by 100, however 2000 was a leap year as it is divisible by 400.

The calculation is proleptic - applying the same rules into the far future and far past. This is historically inaccurate, but is correct for the ISO-8601 standard.
[中]

代码示例

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Returns the length of the year.
 * <p>
 * This returns the length of the year in days, either 365 or 366.
 *
 * @return 366 if the year is leap, 365 otherwise
 */
public int lengthOfYear() {
  return (isLeapYear() ? 366 : 365);
}

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Returns the length of the month, taking account of the year.
 * <p>
 * This returns the length of the month in days.
 * For example, a date in January would return 31.
 *
 * @return the length of the month in days, from 28 to 31
 */
public int lengthOfMonth() {
  return getMonth().length(isLeapYear());
}

代码示例来源:origin: shengsiyuan/jdk8

System.out.println(yearMonth);
System.out.println(yearMonth.lengthOfMonth());
System.out.println(yearMonth.isLeapYear());
System.out.println(yearMonth1.lengthOfMonth());
System.out.println(yearMonth1.lengthOfYear());
System.out.println(yearMonth1.isLeapYear());

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