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

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

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

YearMonthDay.isValidDate介绍

[英]Indicates whether the year, month, and day are a valid representation.
[中]

代码示例

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

  1. /**
  2. *
  3. Initializes a {@link YearMonthDay} from the provided values.
  4. * @param year The year.
  5. * @param month The month of the year (in the range 1 through 12)
  6. * @param day The day of the month (in the range 1 through the number of
  7. days in {@code month})
  8. * @exception ArgumentException
  9. Thrown when the {@code year}, {@code month}, or
  10. {@code day} is outside of its acceptable range.
  11. */
  12. public YearMonthDay(int year, int month, int day) {
  13. if (!isValidDate(year, month, day)) {
  14. throw new ArgumentException(CesiumLocalization.getYearMonthDayInvalidArgument());
  15. }
  16. // fields are stored zero-indexed
  17. m_year = year - 1;
  18. m_month = month - 1;
  19. m_day = day - 1;
  20. }

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

  1. m_month--;
  2. m_day--;
  3. if (!isValidDate(m_year + 1, m_month + 1, m_day + 1)) {
  4. throw new ArgumentOutOfRangeException(CesiumLocalization.getYearMonthDayInvalidArgument());

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

  1. Assert.assertFalse(YearMonthDay.isValidDate(2000, 0, 1));
  2. Assert.assertTrue(YearMonthDay.isValidDate(2000, 1, 1));
  3. Assert.assertTrue(YearMonthDay.isValidDate(2000, 2, 1));
  4. Assert.assertTrue(YearMonthDay.isValidDate(2000, 3, 1));
  5. Assert.assertTrue(YearMonthDay.isValidDate(2000, 4, 1));
  6. Assert.assertTrue(YearMonthDay.isValidDate(2000, 5, 1));
  7. Assert.assertTrue(YearMonthDay.isValidDate(2000, 6, 1));
  8. Assert.assertTrue(YearMonthDay.isValidDate(2000, 7, 1));
  9. Assert.assertTrue(YearMonthDay.isValidDate(2000, 8, 1));
  10. Assert.assertTrue(YearMonthDay.isValidDate(2000, 9, 1));
  11. Assert.assertTrue(YearMonthDay.isValidDate(2000, 10, 1));
  12. Assert.assertTrue(YearMonthDay.isValidDate(2000, 11, 1));
  13. Assert.assertTrue(YearMonthDay.isValidDate(2000, 12, 1));
  14. Assert.assertFalse(YearMonthDay.isValidDate(2000, 13, 1));
  15. for (int month = 1; month < 13; ++month) {
  16. int daysInMonth = YearMonthDay.daysInMonth(2000, month);
  17. Assert.assertFalse(YearMonthDay.isValidDate(2000, month, 0));
  18. for (int day = 1; day < daysInMonth + 1; ++day) {
  19. Assert.assertTrue(YearMonthDay.isValidDate(2000, month, day));
  20. Assert.assertFalse(YearMonthDay.isValidDate(2000, month, daysInMonth + 1));

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

  1. return false;
  2. if (!YearMonthDay.isValidDate(year, month, day)) {
  3. return false;

代码示例来源: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. }

相关文章