src/share/classes/java/time/chrono/HijrahDeviationReader.java

Print this page

        

@@ -52,11 +52,11 @@
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-package java.time.calendar;
+package java.time.chrono;
 
 
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;

@@ -65,13 +65,12 @@
 import java.io.InputStreamReader;
 import java.nio.file.FileSystems;
 import java.security.AccessController;
 import java.text.ParseException;
 import java.time.LocalDate;
-import java.time.format.DateTimeFormatters;
+import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoField;
-import java.time.temporal.ChronoLocalDate;
 import java.util.Arrays;
 import java.util.function.Block;
 
 /**
  * A reader for Hijrah Deviation files.

@@ -83,11 +82,11 @@
  * The default location of the deviation files is
  * {@code <java.home> + FILE_SEP + "lib"}.
  * The deviation files are named {@code "hijrah_" + ID}.
  * <p>
  * The deviation file for a calendar can be overridden by defining the
- * property {@code java.time.calendar.HijrahChrono.File.hijrah_<ID>}
+ * property {@code java.time.chrono.HijrahChronology.File.hijrah_<ID>}
  * with the full pathname of the deviation file.
  * <p>
  * The deviation file is read line by line:
  * <ul>
  * <li>The "#" character begins a comment -

@@ -131,19 +130,19 @@
      *
      * @throws IOException for zip/jar file handling exception.
      * @throws ParseException if the format of the configuration file is wrong.
      */
     static boolean readDeviation(String typeId, String calendarType,
-            Block<HijrahChrono.Deviation> block) throws IOException, ParseException {
+            Block<HijrahChronology.Deviation> block) throws IOException, ParseException {
         InputStream is = getConfigFileInputStream(typeId);
         if (is != null) {
             try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
                 String line = "";
                 int num = 0;
                 while ((line = br.readLine()) != null) {
                     num++;
-                    HijrahChrono.Deviation entry = parseLine(line, num);
+                    HijrahChronology.Deviation entry = parseLine(line, num);
                     if (entry != null) {
                         block.accept(entry);
                     }
                 }
             }

@@ -158,11 +157,11 @@
      * @param line  a line to parse
      * @param num  line number
      * @return an Entry or null if the line is empty.
      * @throws ParseException if line has incorrect format.
      */
-    private static HijrahChrono.Deviation parseLine(final String line, final int num) throws ParseException {
+    private static HijrahChronology.Deviation parseLine(final String line, final int num) throws ParseException {
         int hash = line.indexOf("#");
         String nocomment = (hash < 0) ? line : line.substring(0, hash);
         String[] split = nocomment.split("\\s");
         if (split.length == 0 || split[0].isEmpty()) {
             return null;    // Nothing to parse

@@ -172,20 +171,20 @@
         }
 
         //element [0] is a date
         //element [1] is the offset
 
-        LocalDate isoDate = DateTimeFormatters.pattern("MMM-dd-yyyy").parse(split[0], LocalDate::from);
+        LocalDate isoDate = DateTimeFormatter.ofPattern("MMM-dd-yyyy").parse(split[0], LocalDate::from);
         int offset = Integer.valueOf(split[1]);
 
         // Convert date to HijrahDate using the default Islamic Calendar
 
-        ChronoLocalDate<HijrahChrono> hijrahDate = HijrahChrono.INSTANCE.date(isoDate);
+        HijrahDate hijrahDate = HijrahChronology.INSTANCE.date(isoDate);
 
         int year = hijrahDate.get(ChronoField.YEAR);
         int month = hijrahDate.get(ChronoField.MONTH_OF_YEAR);
-        return new HijrahChrono.Deviation(year, month, year, month, offset);
+        return new HijrahChronology.Deviation(year, month, year, month, offset);
     }
 
 
     /**
      * Return InputStream for deviation configuration file. The default location

@@ -196,25 +195,24 @@
      * <pre>
      *   hijrah_ + typeId + .cfg
      * </pre> The default location and file name can be overridden by setting
      * following two Java system properties.
      * <pre>
-     *   Location: java.time.calendar.HijrahDate.deviationConfigDir
-     *   File name: java.time.calendar.HijrahDate.File. + typeid
+     *   Location: java.time.chrono.HijrahDate.deviationConfigDir
+     *   File name: java.time.chrono.HijrahDate.File. + typeid
      * </pre> Regarding the file format, see readDeviationConfig() method for
      * details.
      *
      * @param typeId the name of the calendar deviation data
      * @return InputStream for file reading.
      * @throws IOException for zip/jar file handling exception.
      */
     private static InputStream getConfigFileInputStream(final String typeId) throws IOException {
         try {
-            InputStream stream =
-                    (InputStream)AccessController
-                    .doPrivileged((java.security.PrivilegedExceptionAction) () -> {
-                String propFilename = "java.time.calendar.HijrahChrono.File." + typeId;
+            InputStream stream = AccessController
+                    .doPrivileged((java.security.PrivilegedExceptionAction<InputStream>) () -> {
+                String propFilename = "java.time.chrono.HijrahChronology.File." + typeId;
                 String filename = System.getProperty(propFilename);
                 File file = null;
                 if (filename != null) {
                     file = new File(filename);
                 } else {