private static void checkCalendarYear(Calendar calendar) { int year = calendar.get(Calendar.YEAR); if (calendar.get(Calendar.ERA) == GregorianCalendar.BC) { year *= -1; } checkAndCastYear(year); }
_calendar.set(Calendar.MONTH, checkAndCastMonth(zmonth) - 1); case YEAR: _calendar.set(Calendar.YEAR, checkAndCastYear(zyear));
this._year = checkAndCastYear(year);
this._year = checkAndCastYear(cal.get(Calendar.YEAR));
_month = checkAndCastMonth(zmonth); case YEAR: _year = checkAndCastYear(zyear);
/** * This method uses deprecated methods from {@link java.util.Date} * instead of {@link Calendar} so that this code can be used (more easily) * on the mobile Java platform (which has Date but does not have Calendar). */ @SuppressWarnings("deprecation") private void set_fields_from_millis(long millis) { if(millis < MINIMUM_ALLOWED_TIMESTAMP_IN_MILLIS){ throw new IllegalArgumentException("year is less than 1"); } Date date = new Date(millis); // These fields are in the system timezone! this._year = checkAndCastYear(date.getYear() + 1900); this._month = checkAndCastMonth(date.getMonth() + 1); // calendar months are 0 based, timestamp months are 1 based this._day = checkAndCastDay(date.getDate(), _year, _month); this._hour = checkAndCastHour(date.getHours()); this._minute = checkAndCastMinute(date.getMinutes()); this._second = checkAndCastSecond(date.getSeconds()); // this is done because the y-m-d values are in the local timezone // so this adjusts the value back to zulu time (UTC) // Note that the sign on this is opposite of Ion (and Calendar) offset. // Example: PST = 480 here but Ion/Calendar use -480 = -08:00 = UTC-8 int offset = date.getTimezoneOffset(); this.apply_offset(-offset); }
_month = checkAndCastMonth(zmonth); case YEAR: _year = checkAndCastYear(zyear);
/** * This method uses deprecated methods from {@link java.util.Date} * instead of {@link Calendar} so that this code can be used (more easily) * on the mobile Java platform (which has Date but does not have Calendar). */ @SuppressWarnings("deprecation") private void set_fields_from_millis(long millis) { Date date = new Date(millis); // These fields are in the system timezone! this._year = checkAndCastYear(date.getYear() + 1900); this._month = checkAndCastMonth(date.getMonth() + 1); // calendar months are 0 based, timestamp months are 1 based this._day = checkAndCastDay(date.getDate(), _year, _month); this._hour = checkAndCastHour(date.getHours()); this._minute = checkAndCastMinute(date.getMinutes()); this._second = checkAndCastSecond(date.getSeconds()); // this is done because the y-m-d values are in the local timezone // so this adjusts the value back to zulu time (UTC) // Note that the sign on this is opposite of Ion (and Calendar) offset. // Example: PST = 480 here but Ion/Calendar use -480 = -08:00 = UTC-8 int offset = date.getTimezoneOffset(); this.apply_offset(-offset); }