/** * Static initialization of the predefined calendars found in the lib/calendars.properties file. */ static { try { calendarProperties = j86.sun.util.calendar.BaseCalendar.getCalendarProperties(); } catch (IOException ioe) { throw new InternalError("Can't initialize lib/calendars.properties", ioe); } try { INSTANCE = new HijrahChronology("Hijrah-umalqura"); // Register it by its aliases AbstractChronology.registerChrono(INSTANCE, "Hijrah"); AbstractChronology.registerChrono(INSTANCE, "islamic"); } catch (DateTimeException ex) { // Absence of Hijrah calendar is fatal to initializing this class. PlatformLogger logger = PlatformLogger.getLogger("j86.java.time.chrono"); logger.severe("Unable to initialize Hijrah calendar: Hijrah-umalqura", ex); throw new RuntimeException("Unable to initialize Hijrah-umalqura calendar", ex.getCause()); } registerVariants(); }
/** * For each Hijrah variant listed, create the HijrahChronology and register it. Exceptions during * initialization are logged but otherwise ignored. */ private static void registerVariants() { for (String name : calendarProperties.stringPropertyNames()) { if (name.startsWith(PROP_PREFIX)) { String id = name.substring(PROP_PREFIX.length()); if (id.indexOf('.') >= 0) { continue; // no name or not a simple name of a calendar } if (id.equals(INSTANCE.getId())) { continue; // do not duplicate the default } try { // Create and register the variant HijrahChronology chrono = new HijrahChronology(id); AbstractChronology.registerChrono(chrono); } catch (DateTimeException ex) { // Log error and continue PlatformLogger logger = PlatformLogger.getLogger("j86.java.time.chrono"); logger.severe("Unable to initialize Hijrah calendar: " + id, ex); } } } }