src/share/classes/sun/util/calendar/LocalGregorianCalendar.java

Print this page
rev 3509 : 7021209: convert lang, math, util to use try-with-resources
Reviewed-by: XXX


 110                 }
 111             }
 112             sb.append(getYear()).append('.');
 113             CalendarUtils.sprintf0d(sb, getMonth(), 2).append('.');
 114             CalendarUtils.sprintf0d(sb, getDayOfMonth(), 2);
 115             sb.append(time);
 116             return sb.toString();
 117         }
 118     }
 119 
 120     static LocalGregorianCalendar getLocalGregorianCalendar(String name) {
 121         Properties calendarProps = null;
 122         try {
 123             String homeDir = AccessController.doPrivileged(
 124                 new sun.security.action.GetPropertyAction("java.home"));
 125             final String fname = homeDir + File.separator + "lib" + File.separator
 126                                  + "calendars.properties";
 127             calendarProps = (Properties) AccessController.doPrivileged(new PrivilegedExceptionAction() {
 128                 public Object run() throws IOException {
 129                     Properties props = new Properties();
 130                     props.load(new FileInputStream(fname));


 131                     return props;
 132                 }
 133             });
 134         } catch (PrivilegedActionException e) {
 135             throw new RuntimeException(e.getException());
 136         }
 137 
 138         // Parse calendar.*.eras
 139         String props = calendarProps.getProperty("calendar." + name + ".eras");
 140         if (props == null) {
 141             return null;
 142         }
 143         List<Era> eras = new ArrayList<Era>();
 144         StringTokenizer eraTokens = new StringTokenizer(props, ";");
 145         while (eraTokens.hasMoreTokens()) {
 146             String items = eraTokens.nextToken().trim();
 147             StringTokenizer itemTokens = new StringTokenizer(items, ",");
 148             String eraName = null;
 149             boolean localTime = true;
 150             long since = 0;




 110                 }
 111             }
 112             sb.append(getYear()).append('.');
 113             CalendarUtils.sprintf0d(sb, getMonth(), 2).append('.');
 114             CalendarUtils.sprintf0d(sb, getDayOfMonth(), 2);
 115             sb.append(time);
 116             return sb.toString();
 117         }
 118     }
 119 
 120     static LocalGregorianCalendar getLocalGregorianCalendar(String name) {
 121         Properties calendarProps = null;
 122         try {
 123             String homeDir = AccessController.doPrivileged(
 124                 new sun.security.action.GetPropertyAction("java.home"));
 125             final String fname = homeDir + File.separator + "lib" + File.separator
 126                                  + "calendars.properties";
 127             calendarProps = (Properties) AccessController.doPrivileged(new PrivilegedExceptionAction() {
 128                 public Object run() throws IOException {
 129                     Properties props = new Properties();
 130                     try (FileInputStream fis = new FileInputStream(fname)) {
 131                         props.load(fis);
 132                     }
 133                     return props;
 134                 }
 135             });
 136         } catch (PrivilegedActionException e) {
 137             throw new RuntimeException(e.getException());
 138         }
 139 
 140         // Parse calendar.*.eras
 141         String props = calendarProps.getProperty("calendar." + name + ".eras");
 142         if (props == null) {
 143             return null;
 144         }
 145         List<Era> eras = new ArrayList<Era>();
 146         StringTokenizer eraTokens = new StringTokenizer(props, ";");
 147         while (eraTokens.hasMoreTokens()) {
 148             String items = eraTokens.nextToken().trim();
 149             StringTokenizer itemTokens = new StringTokenizer(items, ",");
 150             String eraName = null;
 151             boolean localTime = true;
 152             long since = 0;