private static int resolvePreviousValid(int year, int month, int day) { switch (month) { case 2: day = Math.min(day, IsoChronology.INSTANCE.isLeapYear(year) ? 29 : 28); break; case 4: case 6: case 9: case 11: day = Math.min(day, 30); break; } return pack((short) year, (byte) month, (byte) day); }
public static boolean isLeapYear(int packedDate) { return IsoChronology.INSTANCE.isLeapYear(getYear(packedDate)); }
public static boolean isLeapYear(long packedDateTime) { if (packedDateTime == missingValueIndicator()) return false; return IsoChronology.INSTANCE.isLeapYear(getYear(packedDateTime)); }
/** * Checks if the specified year is a leap year. * <p> * Thai Buddhist leap years occur exactly in line with ISO leap years. * This method does not validate the year passed in, and only has a * well-defined result for years in the supported range. * * @param prolepticYear the proleptic-year to check, not validated for range * @return true if the year is a leap year */ @Override public boolean isLeapYear(long prolepticYear) { return IsoChronology.INSTANCE.isLeapYear(prolepticYear - YEARS_DIFFERENCE); }
/** * Checks if the specified year is a leap year. * <p> * Japanese calendar leap years occur exactly in line with ISO leap years. * This method does not validate the year passed in, and only has a * well-defined result for years in the supported range. * * @param prolepticYear the proleptic-year to check, not validated for range * @return true if the year is a leap year */ @Override public boolean isLeapYear(long prolepticYear) { return IsoChronology.INSTANCE.isLeapYear(prolepticYear); }
/** * Checks if the specified year is a leap year. * <p> * Minguo leap years occur exactly in line with ISO leap years. * This method does not validate the year passed in, and only has a * well-defined result for years in the supported range. * * @param prolepticYear the proleptic-year to check, not validated for range * @return true if the year is a leap year */ @Override public boolean isLeapYear(long prolepticYear) { return IsoChronology.INSTANCE.isLeapYear(prolepticYear + YEARS_DIFFERENCE); }
/** * Checks if the year is a leap year, according to the ISO proleptic * calendar system rules. * <p> * 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. * <p> * 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. * <p> * 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. * * @return true if the year is leap, false otherwise */ public boolean isLeapYear() { return IsoChronology.INSTANCE.isLeapYear(year); }
/** * Checks if the year is a leap year, according to the ISO proleptic * calendar system rules. * <p> * 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. * <p> * 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. * <p> * 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. * * @return true if the year is leap, false otherwise */ public boolean isLeapYear() { return IsoChronology.INSTANCE.isLeapYear(year); }
/** * Checks if the year is a leap year, according to the ISO proleptic * calendar system rules. * <p> * 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. * <p> * 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. * <p> * 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. * * @return true if the year is leap, false otherwise */ @Override // override for Javadoc and performance public boolean isLeapYear() { return IsoChronology.INSTANCE.isLeapYear(year); }
/** * Resolves the date, resolving days past the end of month. * * @param year the year to represent, validated from MIN_YEAR to MAX_YEAR * @param month the month-of-year to represent, validated from 1 to 12 * @param day the day-of-month to represent, validated from 1 to 31 * @return the resolved date, not null */ private static LocalDate resolvePreviousValid(int year, int month, int day) { switch (month) { case 2: day = Math.min(day, IsoChronology.INSTANCE.isLeapYear(year) ? 29 : 28); break; case 4: case 6: case 9: case 11: day = Math.min(day, 30); break; } return LocalDate.of(year, month, day); }
public static boolean isLeapYear(int packedDate) { return IsoChronology.INSTANCE.isLeapYear(getYear(packedDate)); }
public static boolean isLeapYear(int packedDate) { return IsoChronology.INSTANCE.isLeapYear(getYear(packedDate)); }
private static int resolvePreviousValid(int year, int month, int day) { switch (month) { case 2: day = Math.min(day, IsoChronology.INSTANCE.isLeapYear(year) ? 29 : 28); break; case 4: case 6: case 9: case 11: day = Math.min(day, 30); break; } return pack((short) year, (byte) month, (byte) day); }
public static boolean isLeapYear(long packedDateTime) { return IsoChronology.INSTANCE.isLeapYear(getYear(packedDateTime)); }
/** * Checks if the specified year is a leap year. * <p> * The result will return the same as {@link JulianChronology#isLeapYear(long)} for * year 1752 and earlier, and {@link IsoChronology#isLeapYear(long)} otherwise. * This method does not validate the year passed in, and only has a * well-defined result for years in the supported range. * * @param prolepticYear the proleptic-year to check, not validated for range * @return true if the year is a leap year */ @Override public boolean isLeapYear(long prolepticYear) { if (prolepticYear <= CUTOVER_YEAR) { return JulianChronology.INSTANCE.isLeapYear(prolepticYear); } return IsoChronology.INSTANCE.isLeapYear(prolepticYear); }
public static boolean isLeapYear(long packedDateTime) { if (packedDateTime == missingValueIndicator()) return false; return IsoChronology.INSTANCE.isLeapYear(getYear(packedDateTime)); }
private LocalDate toLocalDate() { LocalDate date; if (dayOfMonthIndicator < 0) { int monthLen = month.length(IsoChronology.INSTANCE.isLeapYear(year)); date = LocalDate.of(year, month, monthLen + 1 + dayOfMonthIndicator); if (dayOfWeek != null) { date = date.with(previousOrSame(dayOfWeek)); } } else { date = LocalDate.of(year, month, dayOfMonthIndicator); if (dayOfWeek != null) { date = date.with(nextOrSame(dayOfWeek)); } } if (timeEndOfDay) { date = date.plusDays(1); } return date; }
@Override public long getFrom(TemporalAccessor temporal) { if (temporal.isSupported(this) == false) { throw new UnsupportedTemporalTypeException("Unsupported field: DayOfQuarter"); } int doy = temporal.get(DAY_OF_YEAR); int moy = temporal.get(MONTH_OF_YEAR); long year = temporal.getLong(YEAR); return doy - QUARTER_DAYS[((moy - 1) / 3) + (IsoChronology.INSTANCE.isLeapYear(year) ? 4 : 0)]; } @SuppressWarnings("unchecked")
/** * Creates a local date from the year, month and day fields. * * @param year the year to represent, validated from MIN_YEAR to MAX_YEAR * @param month the month-of-year to represent, validated not null * @param dayOfMonth the day-of-month to represent, validated from 1 to 31 * @return the local date, not null * @throws DateTimeException if the day-of-month is invalid for the month-year */ private static LocalDate create(int year, Month month, int dayOfMonth) { if (dayOfMonth > 28 && dayOfMonth > month.length(IsoChronology.INSTANCE.isLeapYear(year))) { if (dayOfMonth == 29) { throw new DateTimeException("Invalid date 'February 29' as '" + year + "' is not a leap year"); } else { throw new DateTimeException("Invalid date '" + month.name() + " " + dayOfMonth + "'"); } } return new LocalDate(year, month.getValue(), dayOfMonth); }
@Override public ValueRange rangeRefinedBy(TemporalAccessor temporal) { if (temporal.isSupported(this) == false) { throw new UnsupportedTemporalTypeException("Unsupported field: DayOfQuarter"); } long qoy = temporal.getLong(QUARTER_OF_YEAR); if (qoy == 1) { long year = temporal.getLong(YEAR); return (IsoChronology.INSTANCE.isLeapYear(year) ? ValueRange.of(1, 91) : ValueRange.of(1, 90)); } else if (qoy == 2) { return ValueRange.of(1, 91); } else if (qoy == 3 || qoy == 4) { return ValueRange.of(1, 92); } // else value not from 1 to 4, so drop through return range(); } @Override