/** * Gets an instance of the IslamicChronology in the given time zone. * * @param zone the time zone to get the chronology in, null is default * @param leapYears the type defining the leap year pattern * @return a chronology in the specified time zone */ public static IslamicChronology getInstance(DateTimeZone zone, LeapYearPatternType leapYears) { if (zone == null) { zone = DateTimeZone.getDefault(); } IslamicChronology chrono; synchronized (cCache) { IslamicChronology[] chronos = (IslamicChronology[]) cCache.get(zone); if (chronos == null) { chronos = new IslamicChronology[4]; cCache.put(zone, chronos); } chrono = chronos[leapYears.index]; if (chrono == null) { if (zone == DateTimeZone.UTC) { // First create without a lower limit. chrono = new IslamicChronology(null, null, leapYears); // Impose lower limit and make another IslamicChronology. DateTime lowerLimit = new DateTime(1, 1, 1, 0, 0, 0, 0, chrono); chrono = new IslamicChronology( LimitChronology.getInstance(chrono, lowerLimit, null), null, leapYears); } else { chrono = getInstance(DateTimeZone.UTC, leapYears); chrono = new IslamicChronology(ZonedChronology.getInstance(chrono, zone), null, leapYears); } chronos[leapYears.index] = chrono; } } return chrono; }
/** * 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 synchronized BuddhistChronology getInstance(DateTimeZone zone) { if (zone == null) { zone = DateTimeZone.getDefault(); } BuddhistChronology chrono = (BuddhistChronology) 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), ""); cCache.put(zone, chrono); } return chrono; }