コード例 #1
0
 /**
  * Initializes a {@link YearMonthDay} from the provided values.
  *
  * @param year The year.
  * @param month The month of the year (in the range 1 through 12)
  * @param day The day of the month (in the range 1 through the number of days in {@code month})
  * @exception ArgumentException Thrown when the {@code year}, {@code month}, or {@code day} is
  *     outside of its acceptable range.
  */
 public YearMonthDay(int year, int month, int day) {
   if (isValidDate(year, month, day)) {
     // fields are stored zero-indexed
     m_year = year - 1;
     m_month = month - 1;
     m_day = day - 1;
   } else {
     throw new ArgumentException(CesiumLocalization.getYearMonthDayInvalidArgument());
   }
 }
コード例 #2
0
 /**
  * Initializes a {@link YearMonthDay} from the provided values.
  *
  * @param year The year.
  * @param dayOfYear The day of the year (in the range 1 through the number of days in the year).
  */
 public YearMonthDay(int year, int dayOfYear) {
   if (dayOfYear <= daysInYear(year)) {
     // year is stored zero-indexed
     m_year = year - 1;
     int[] cumulativeDays =
         isLeapYear(year) ? s_leapYearCumulativeMonthTable : s_commonYearCumulativeMonthTable;
     // month is stored zero-indexed
     for (m_month = 11; m_month > 0; --m_month) {
       if (cumulativeDays[m_month] < dayOfYear) {
         break;
       }
     }
     // day is stored zero-indexed
     m_day = dayOfYear - cumulativeDays[m_month] - 1;
     if (!isValidDate(m_year + 1, m_month + 1, m_day + 1)) {
       throw new ArgumentException(CesiumLocalization.getYearMonthDayInvalidArgument());
     }
   } else {
     throw new ArgumentException(CesiumLocalization.getYearMonthDayInvalidArgument());
   }
 }
コード例 #3
0
 /**
  * Initializes a {@link YearMonthDay} in the Gregorian calendar from the provided astronomical
  * Julian day number, assuming the beginning of the Julian day (noon).
  *
  * @param astronomicalJulianDayNumber The astronomical Julian day number.
  */
 @CS2JWarning("Unhandled attribute removed: SuppressMessage")
 public YearMonthDay(int astronomicalJulianDayNumber) {
   // Algorithm from page 604 of the Explanatory Supplement to the
   // Astronomical Almanac (Seidelmann 1992).
   int L = astronomicalJulianDayNumber + 68569;
   int N = 4 * L / 146097;
   L = L - (146097 * N + 3) / 4;
   int I = (4000 * (L + 1)) / 1461001;
   L = L - (1461 * I) / 4 + 31;
   int J = (80 * L) / 2447;
   m_day = L - (2447 * J) / 80;
   L = J / 11;
   m_month = J + 2 - 12 * L;
   m_year = 100 * (N - 49) + I + L;
   m_year--;
   m_month--;
   m_day--;
   if (!isValidDate(m_year + 1, m_month + 1, m_day + 1)) {
     throw new ArgumentOutOfRangeException(CesiumLocalization.getYearMonthDayInvalidArgument());
   }
 }