/** * Serialization singleton. */ private Object readResolve() { Chronology base = getBase(); int minDays = getMinimumDaysInFirstWeek(); minDays = (minDays == 0 ? 4 : minDays); // handle rename of BaseGJChronology return base == null ? getInstance(DateTimeZone.UTC, minDays) : getInstance(base.getZone(), minDays); }
if (zone == DateTimeZone.UTC) { chrono = new CopticChronology(null, null, minDaysInFirstWeek); chrono = new CopticChronology (LimitChronology.getInstance(chrono, lowerLimit, null), null, minDaysInFirstWeek); } else { chrono = getInstance(DateTimeZone.UTC, minDaysInFirstWeek); chrono = new CopticChronology (ZonedChronology.getInstance(chrono, zone), null, minDaysInFirstWeek);
/** * Gets the Chronology in a specific time zone. * * @param zone the zone to get the chronology in, null is default * @return the chronology */ public Chronology withZone(DateTimeZone zone) { if (zone == null) { zone = DateTimeZone.getDefault(); } if (zone == getZone()) { return this; } return getInstance(zone); }
@Override boolean isLeapDay(long instant) { return dayOfMonth().get(instant) == 6 && monthOfYear().isLeap(instant); }
/** * Gets an instance of the CopticChronology in the given time zone. * * @param zone the time zone to get the chronology in, null is default * @return a chronology in the specified time zone */ public static CopticChronology getInstance(DateTimeZone zone) { return getInstance(zone, 4); }
protected void assemble(Fields fields) { if (getBase() == null) { super.assemble(fields); // Coptic, like Julian, has no year zero. fields.year = new SkipDateTimeField(this, fields.year); fields.weekyear = new SkipDateTimeField(this, fields.weekyear); fields.era = ERA_FIELD; fields.monthOfYear = new BasicMonthOfYearDateTimeField(this, 13); fields.months = fields.monthOfYear.getDurationField(); } }
long calculateFirstDayOfYearMillis(int year) { // Java epoch is 1970-01-01 Gregorian which is 1686-04-23 Coptic. // Calculate relative to the nearest leap year and account for the // difference later. int relativeYear = year - 1687; int leapYears; if (relativeYear <= 0) { // Add 3 before shifting right since /4 and >>2 behave differently // on negative numbers. leapYears = (relativeYear + 3) >> 2; } else { leapYears = relativeYear >> 2; // For post 1687 an adjustment is needed as jan1st is before leap day if (!isLeapYear(year)) { leapYears++; } } long millis = (relativeYear * 365L + leapYears) * (long)DateTimeConstants.MILLIS_PER_DAY; // Adjust to account for difference between 1687-01-01 and 1686-04-23. return millis + (365L - 112) * DateTimeConstants.MILLIS_PER_DAY; }
/** * Gets an instance of the CopticChronology in the given time zone. * * @param zone the time zone to get the chronology in, null is default * @return a chronology in the specified time zone */ public static CopticChronology getInstance(DateTimeZone zone) { return getInstance(zone, 4); }
protected void assemble(Fields fields) { if (getBase() == null) { super.assemble(fields); // Coptic, like Julian, has no year zero. fields.year = new SkipDateTimeField(this, fields.year); fields.weekyear = new SkipDateTimeField(this, fields.weekyear); fields.era = ERA_FIELD; fields.monthOfYear = new BasicMonthOfYearDateTimeField(this, 13); fields.months = fields.monthOfYear.getDurationField(); } }
long calculateFirstDayOfYearMillis(int year) { // Java epoch is 1970-01-01 Gregorian which is 1686-04-23 Coptic. // Calculate relative to the nearest leap year and account for the // difference later. int relativeYear = year - 1687; int leapYears; if (relativeYear <= 0) { // Add 3 before shifting right since /4 and >>2 behave differently // on negative numbers. leapYears = (relativeYear + 3) >> 2; } else { leapYears = relativeYear >> 2; // For post 1687 an adjustment is needed as jan1st is before leap day if (!isLeapYear(year)) { leapYears++; } } long millis = (relativeYear * 365L + leapYears) * (long)DateTimeConstants.MILLIS_PER_DAY; // Adjust to account for difference between 1687-01-01 and 1686-04-23. return millis + (365L - 112) * DateTimeConstants.MILLIS_PER_DAY; }
@Override boolean isLeapDay(long instant) { return dayOfMonth().get(instant) == 6 && monthOfYear().isLeap(instant); }
/** * Serialization singleton. */ private Object readResolve() { Chronology base = getBase(); int minDays = getMinimumDaysInFirstWeek(); minDays = (minDays == 0 ? 4 : minDays); // handle rename of BaseGJChronology return base == null ? getInstance(DateTimeZone.UTC, minDays) : getInstance(base.getZone(), minDays); }
/** * Gets the Chronology in a specific time zone. * * @param zone the zone to get the chronology in, null is default * @return the chronology */ public Chronology withZone(DateTimeZone zone) { if (zone == null) { zone = DateTimeZone.getDefault(); } if (zone == getZone()) { return this; } return getInstance(zone); }
if (zone == DateTimeZone.UTC) { chrono = new CopticChronology(null, null, minDaysInFirstWeek); chrono = new CopticChronology (LimitChronology.getInstance(chrono, lowerLimit, null), null, minDaysInFirstWeek); } else { chrono = getInstance(DateTimeZone.UTC, minDaysInFirstWeek); chrono = new CopticChronology (ZonedChronology.getInstance(chrono, zone), null, minDaysInFirstWeek);
/** * Gets an instance of the CopticChronology in the default time zone. * * @return a chronology in the default time zone */ public static CopticChronology getInstance() { return getInstance(DateTimeZone.getDefault(), 4); }
protected void assemble(Fields fields) { if (getBase() == null) { super.assemble(fields); // Coptic, like Julian, has no year zero. fields.year = new SkipDateTimeField(this, fields.year); fields.weekyear = new SkipDateTimeField(this, fields.weekyear); fields.era = ERA_FIELD; fields.monthOfYear = new BasicMonthOfYearDateTimeField(this, 13); fields.months = fields.monthOfYear.getDurationField(); } }
long calculateFirstDayOfYearMillis(int year) { // Java epoch is 1970-01-01 Gregorian which is 1686-04-23 Coptic. // Calculate relative to the nearest leap year and account for the // difference later. int relativeYear = year - 1687; int leapYears; if (relativeYear <= 0) { // Add 3 before shifting right since /4 and >>2 behave differently // on negative numbers. leapYears = (relativeYear + 3) >> 2; } else { leapYears = relativeYear >> 2; // For post 1687 an adjustment is needed as jan1st is before leap day if (!isLeapYear(year)) { leapYears++; } } long millis = (relativeYear * 365L + leapYears) * (long)DateTimeConstants.MILLIS_PER_DAY; // Adjust to account for difference between 1687-01-01 and 1686-04-23. return millis + (365L - 112) * DateTimeConstants.MILLIS_PER_DAY; }
@Override boolean isLeapDay(long instant) { return dayOfMonth().get(instant) == 6 && monthOfYear().isLeap(instant); }
/** * Serialization singleton. */ private Object readResolve() { Chronology base = getBase(); int minDays = getMinimumDaysInFirstWeek(); minDays = (minDays == 0 ? 4 : minDays); // handle rename of BaseGJChronology return base == null ? getInstance(DateTimeZone.UTC, minDays) : getInstance(base.getZone(), minDays); }
/** * Gets the Chronology in a specific time zone. * * @param zone the zone to get the chronology in, null is default * @return the chronology */ public Chronology withZone(DateTimeZone zone) { if (zone == null) { zone = DateTimeZone.getDefault(); } if (zone == getZone()) { return this; } return getInstance(zone); }