cesiumlanguagewriter.YearMonthDay.daysInYear()方法的使用及代码示例

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

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

YearMonthDay.daysInYear介绍

[英]Provides the number of days in the indicated year.
[中]提供指定年份中的天数。

代码示例

代码示例来源:origin: AnalyticalGraphicsInc/czml-writer

  1. /**
  2. *
  3. Tests that years divisible by 4, except for years which are both divisible
  4. by 100 and not divisible by 400, have 366 days instead of 365.
  5. */
  6. @Test
  7. public final void testDaysInYear() {
  8. for (int i = 1; i < 10000; ++i) {
  9. if ((i % 4 == 0) && !((i % 100 == 0) && (i % 400 != 0))) {
  10. Assert.assertEquals((int) 366, (int) YearMonthDay.daysInYear(i));
  11. } else {
  12. Assert.assertEquals((int) 365, (int) YearMonthDay.daysInYear(i));
  13. }
  14. }
  15. }

代码示例来源:origin: AnalyticalGraphicsInc/czml-writer

  1. /**
  2. *
  3. Initializes a {@link YearMonthDay} from the provided values.
  4. * @param year The year.
  5. * @param dayOfYear The day of the year
  6. (in the range 1 through the number of days in the year).
  7. */
  8. public YearMonthDay(int year, int dayOfYear) {
  9. if (dayOfYear > daysInYear(year)) {
  10. throw new ArgumentException(CesiumLocalization.getYearMonthDayInvalidArgument(), "dayOfYear");
  11. }
  12. // year is stored zero-indexed
  13. m_year = year - 1;
  14. int[] cumulativeMonthTable = getCumulativeMonthTable(year);
  15. // month is stored zero-indexed
  16. for (m_month = 11; m_month > 0; --m_month) {
  17. if (cumulativeMonthTable[m_month] < dayOfYear) {
  18. break;
  19. }
  20. }
  21. // day is stored zero-indexed
  22. m_day = dayOfYear - cumulativeMonthTable[m_month] - 1;
  23. if (!isValidDate(m_year + 1, m_month + 1, m_day + 1)) {
  24. throw new ArgumentException(CesiumLocalization.getYearMonthDayInvalidArgument());
  25. }
  26. }

相关文章