/** * Wraps another chronology, with datetime limits. When withUTC or * withZone is called, the returned LimitChronology instance has * the same limits, except they are time zone adjusted. * * @param base base chronology to wrap * @param lowerLimit inclusive lower limit, or null if none * @param upperLimit exclusive upper limit, or null if none * @throws IllegalArgumentException if chronology is null or limits are invalid */ public static LimitChronology getInstance(Chronology base, ReadableDateTime lowerLimit, ReadableDateTime upperLimit) { if (base == null) { throw new IllegalArgumentException("Must supply a chronology"); } lowerLimit = lowerLimit == null ? null : lowerLimit.toDateTime(); upperLimit = upperLimit == null ? null : upperLimit.toDateTime(); if (lowerLimit != null && upperLimit != null && !lowerLimit.isBefore(upperLimit)) { throw new IllegalArgumentException ("The lower limit must be come before than the upper limit"); } return new LimitChronology(base, (DateTime)lowerLimit, (DateTime)upperLimit); }
public long getDateTimeMillis(long instant, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) throws IllegalArgumentException { checkLimits(instant, null); instant = getBase().getDateTimeMillis (instant, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond); checkLimits(instant, "resulting"); return instant; }
fields.eras = convertField(fields.eras, converted); fields.centuries = convertField(fields.centuries, converted); fields.years = convertField(fields.years, converted); fields.months = convertField(fields.months, converted); fields.weekyears = convertField(fields.weekyears, converted); fields.weeks = convertField(fields.weeks, converted); fields.days = convertField(fields.days, converted); fields.halfdays = convertField(fields.halfdays, converted); fields.hours = convertField(fields.hours, converted); fields.minutes = convertField(fields.minutes, converted); fields.seconds = convertField(fields.seconds, converted); fields.millis = convertField(fields.millis, converted); fields.year = convertField(fields.year, converted); fields.yearOfEra = convertField(fields.yearOfEra, converted); fields.yearOfCentury = convertField(fields.yearOfCentury, converted); fields.centuryOfEra = convertField(fields.centuryOfEra, converted); fields.era = convertField(fields.era, converted); fields.dayOfWeek = convertField(fields.dayOfWeek, converted); fields.dayOfMonth = convertField(fields.dayOfMonth, converted); fields.dayOfYear = convertField(fields.dayOfYear, converted); fields.monthOfYear = convertField(fields.monthOfYear, converted); fields.weekOfWeekyear = convertField(fields.weekOfWeekyear, converted); fields.weekyear = convertField(fields.weekyear, converted); fields.weekyearOfCentury = convertField(fields.weekyearOfCentury, converted); fields.millisOfSecond = convertField(fields.millisOfSecond, converted); fields.millisOfDay = convertField(fields.millisOfDay, converted);
/** * A debugging string for the chronology. * * @return the debugging string */ public String toString() { return "LimitChronology[" + getBase().toString() + ", " + (getLowerLimit() == null ? "NoLimit" : getLowerLimit().toString()) + ", " + (getUpperLimit() == null ? "NoLimit" : getUpperLimit().toString()) + ']'; }
zone = DateTimeZone.getDefault(); if (zone == getZone()) { return this; LimitChronology chrono = getInstance (getBase().withZone(zone), lowerLimit, upperLimit);
public long add(long instant, int amount) { checkLimits(instant, null); long result = getWrappedField().add(instant, amount); checkLimits(result, "resulting"); return result; }
/** * Standard instance of a Buddhist Chronology, that matches * Sun's BuddhistCalendar class. This means that it follows the * GregorianJulian calendar rules with a cutover date. * * @param zone the time zone to use, null is default */ public static BuddhistChronology getInstance(DateTimeZone zone) { if (zone == null) { zone = DateTimeZone.getDefault(); } BuddhistChronology chrono = cCache.get(zone); if (chrono == null) { // First create without a lower limit. chrono = new BuddhistChronology(GJChronology.getInstance(zone, null), null); // Impose lower limit and make another BuddhistChronology. DateTime lowerLimit = new DateTime(1, 1, 1, 0, 0, 0, 0, chrono); chrono = new BuddhistChronology(LimitChronology.getInstance(chrono, lowerLimit, null), ""); BuddhistChronology oldChrono = cCache.putIfAbsent(zone, chrono); if (oldChrono != null) { chrono = oldChrono; } } return chrono; }
/** * If this LimitChronology is already UTC, then this is * returned. Otherwise, a new instance is returned, with the limits * adjusted to the new time zone. */ public Chronology withUTC() { return withZone(DateTimeZone.UTC); }
/** * A debugging string for the chronology. * * @return the debugging string */ public String toString() { return "LimitChronology[" + getBase().toString() + ", " + (getLowerLimit() == null ? "NoLimit" : getLowerLimit().toString()) + ", " + (getUpperLimit() == null ? "NoLimit" : getUpperLimit().toString()) + ']'; }
zone = DateTimeZone.getDefault(); if (zone == getZone()) { return this; LimitChronology chrono = getInstance (getBase().withZone(zone), lowerLimit, upperLimit);
public long set(long instant, String text, Locale locale) { checkLimits(instant, null); long result = getWrappedField().set(instant, text, locale); checkLimits(result, "resulting"); return result; }
/** * Standard instance of a Buddhist Chronology, that matches * Sun's BuddhistCalendar class. This means that it follows the * GregorianJulian calendar rules with a cutover date. * * @param zone the time zone to use, null is default */ public static BuddhistChronology getInstance(DateTimeZone zone) { if (zone == null) { zone = DateTimeZone.getDefault(); } BuddhistChronology chrono = cCache.get(zone); if (chrono == null) { // First create without a lower limit. chrono = new BuddhistChronology(GJChronology.getInstance(zone, null), null); // Impose lower limit and make another BuddhistChronology. DateTime lowerLimit = new DateTime(1, 1, 1, 0, 0, 0, 0, chrono); chrono = new BuddhistChronology(LimitChronology.getInstance(chrono, lowerLimit, null), ""); BuddhistChronology oldChrono = cCache.putIfAbsent(zone, chrono); if (oldChrono != null) { chrono = oldChrono; } } return chrono; }
/** * If this LimitChronology is already UTC, then this is * returned. Otherwise, a new instance is returned, with the limits * adjusted to the new time zone. */ public Chronology withUTC() { return withZone(DateTimeZone.UTC); }
/** * A suitable hashcode for the chronology. * * @return the hashcode * @since 1.4 */ public int hashCode() { int hash = 317351877; hash += (getLowerLimit() != null ? getLowerLimit().hashCode() : 0); hash += (getUpperLimit() != null ? getUpperLimit().hashCode() : 0); hash += getBase().hashCode() * 7; return hash; }
zone = DateTimeZone.getDefault(); if (zone == getZone()) { return this; LimitChronology chrono = getInstance (getBase().withZone(zone), lowerLimit, upperLimit);
public long getDateTimeMillis(long instant, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) throws IllegalArgumentException { checkLimits(instant, null); instant = getBase().getDateTimeMillis (instant, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond); checkLimits(instant, "resulting"); return instant; }
fields.eras = convertField(fields.eras, converted); fields.centuries = convertField(fields.centuries, converted); fields.years = convertField(fields.years, converted); fields.months = convertField(fields.months, converted); fields.weekyears = convertField(fields.weekyears, converted); fields.weeks = convertField(fields.weeks, converted); fields.days = convertField(fields.days, converted); fields.halfdays = convertField(fields.halfdays, converted); fields.hours = convertField(fields.hours, converted); fields.minutes = convertField(fields.minutes, converted); fields.seconds = convertField(fields.seconds, converted); fields.millis = convertField(fields.millis, converted); fields.year = convertField(fields.year, converted); fields.yearOfEra = convertField(fields.yearOfEra, converted); fields.yearOfCentury = convertField(fields.yearOfCentury, converted); fields.centuryOfEra = convertField(fields.centuryOfEra, converted); fields.era = convertField(fields.era, converted); fields.dayOfWeek = convertField(fields.dayOfWeek, converted); fields.dayOfMonth = convertField(fields.dayOfMonth, converted); fields.dayOfYear = convertField(fields.dayOfYear, converted); fields.monthOfYear = convertField(fields.monthOfYear, converted); fields.weekOfWeekyear = convertField(fields.weekOfWeekyear, converted); fields.weekyear = convertField(fields.weekyear, converted); fields.weekyearOfCentury = convertField(fields.weekyearOfCentury, converted); fields.millisOfSecond = convertField(fields.millisOfSecond, converted); fields.millisOfDay = convertField(fields.millisOfDay, converted);
public long roundCeiling(long instant) { checkLimits(instant, null); long result = getWrappedField().roundCeiling(instant); checkLimits(result, "resulting"); return result; }
(LimitChronology.getInstance(chrono, lowerLimit, null), null, minDaysInFirstWeek); } else {
/** * If this LimitChronology is already UTC, then this is * returned. Otherwise, a new instance is returned, with the limits * adjusted to the new time zone. */ public Chronology withUTC() { return withZone(DateTimeZone.UTC); }