src/java.base/share/classes/java/time/chrono/HijrahDate.java

Print this page
rev 12809 : 8023217: Additional floorDiv/floorMod/multiplyExact methods for java.lang.Math
Summary: Add new methods with long, int signatures.
Reviewed-by: XXX
   1 /*
   2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 480         return chrono.getEpochDay(prolepticYear, monthOfYear, dayOfMonth);
 481     }
 482 
 483     /**
 484      * Gets the day-of-year field.
 485      * <p>
 486      * This method returns the primitive {@code int} value for the day-of-year.
 487      *
 488      * @return the day-of-year
 489      */
 490     private int getDayOfYear() {
 491         return chrono.getDayOfYear(prolepticYear, monthOfYear) + dayOfMonth;
 492     }
 493 
 494     /**
 495      * Gets the day-of-week value.
 496      *
 497      * @return the day-of-week; computed from the epochday
 498      */
 499     private int getDayOfWeek() {
 500         int dow0 = (int)Math.floorMod(toEpochDay() + 3, 7);
 501         return dow0 + 1;
 502     }
 503 
 504     /**
 505      * Gets the Era of this date.
 506      *
 507      * @return the Era of this date; computed from epochDay
 508      */
 509     private int getEraValue() {
 510         return (prolepticYear > 1 ? 1 : 0);
 511     }
 512 
 513     //-----------------------------------------------------------------------
 514     /**
 515      * Checks if the year is a leap year, according to the Hijrah calendar system rules.
 516      *
 517      * @return true if this date is in a leap year
 518      */
 519     @Override
 520     public boolean isLeapYear() {


   1 /*
   2  * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 480         return chrono.getEpochDay(prolepticYear, monthOfYear, dayOfMonth);
 481     }
 482 
 483     /**
 484      * Gets the day-of-year field.
 485      * <p>
 486      * This method returns the primitive {@code int} value for the day-of-year.
 487      *
 488      * @return the day-of-year
 489      */
 490     private int getDayOfYear() {
 491         return chrono.getDayOfYear(prolepticYear, monthOfYear) + dayOfMonth;
 492     }
 493 
 494     /**
 495      * Gets the day-of-week value.
 496      *
 497      * @return the day-of-week; computed from the epochday
 498      */
 499     private int getDayOfWeek() {
 500         int dow0 = Math.floorMod(toEpochDay() + 3, 7);
 501         return dow0 + 1;
 502     }
 503 
 504     /**
 505      * Gets the Era of this date.
 506      *
 507      * @return the Era of this date; computed from epochDay
 508      */
 509     private int getEraValue() {
 510         return (prolepticYear > 1 ? 1 : 0);
 511     }
 512 
 513     //-----------------------------------------------------------------------
 514     /**
 515      * Checks if the year is a leap year, according to the Hijrah calendar system rules.
 516      *
 517      * @return true if this date is in a leap year
 518      */
 519     @Override
 520     public boolean isLeapYear() {