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

Print this page

        

@@ -52,27 +52,16 @@
  * 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;
-
-import static java.time.temporal.ChronoField.ERA;
+package java.time.chrono;
 
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.time.DateTimeException;
-import java.time.format.DateTimeFormatterBuilder;
-import java.time.format.TextStyle;
-import java.time.temporal.ChronoField;
-import java.time.temporal.ChronoLocalDate;
-import java.time.temporal.Era;
-import java.time.temporal.Temporal;
-import java.time.temporal.TemporalField;
-import java.time.temporal.ValueRange;
-import java.util.Locale;
 
 /**
  * An era in the Hijrah calendar system.
  * <p>
  * The Hijrah calendar system has two eras.

@@ -84,11 +73,11 @@
  * <h3>Specification for implementors</h3>
  * This is an immutable and thread-safe enum.
  *
  * @since 1.8
  */
-enum HijrahEra implements Era<HijrahChrono> {
+enum HijrahEra implements Era {
 
     /**
      * The singleton instance for the era before the current one, 'Before Anno Hegirae',
      * which has the value 0.
      */

@@ -133,75 +122,27 @@
     public int getValue() {
         return ordinal();
     }
 
     @Override
-    public HijrahChrono getChrono() {
-        return HijrahChrono.INSTANCE;
+    public HijrahChronology getChronology() {
+        return HijrahChronology.INSTANCE;
     }
 
     // JDK8 default methods:
     //-----------------------------------------------------------------------
     @Override
-    public ChronoLocalDate<HijrahChrono> date(int year, int month, int day) {
-        return getChrono().date(this, year, month, day);
+    public HijrahDate date(int year, int month, int day) {
+        return (HijrahDate)(getChronology().date(this, year, month, day));
     }
 
     @Override
-    public ChronoLocalDate<HijrahChrono> dateYearDay(int year, int dayOfYear) {
-        return getChrono().dateYearDay(this, year, dayOfYear);
-    }
-
-    //-----------------------------------------------------------------------
-    @Override
-    public boolean isSupported(TemporalField field) {
-        if (field instanceof ChronoField) {
-            return field == ERA;
-        }
-        return field != null && field.doIsSupported(this);
-    }
-
-    @Override
-    public ValueRange range(TemporalField field) {
-        if (field == ERA) {
-            return field.range();
-        } else if (field instanceof ChronoField) {
-            throw new DateTimeException("Unsupported field: " + field.getName());
-        }
-        return field.doRange(this);
-    }
-
-    @Override
-    public int get(TemporalField field) {
-        if (field == ERA) {
-            return getValue();
-        }
-        return range(field).checkValidIntValue(getLong(field), field);
-    }
-
-    @Override
-    public long getLong(TemporalField field) {
-        if (field == ERA) {
-            return getValue();
-        } else if (field instanceof ChronoField) {
-            throw new DateTimeException("Unsupported field: " + field.getName());
-        }
-        return field.doGet(this);
+    public HijrahDate dateYearDay(int year, int dayOfYear) {
+        return (HijrahDate)(getChronology().dateYearDay(this, year, dayOfYear));
     }
 
     //-------------------------------------------------------------------------
-    @Override
-    public Temporal adjustInto(Temporal temporal) {
-        return temporal.with(ERA, getValue());
-    }
-
-    //-----------------------------------------------------------------------
-    @Override
-    public String getText(TextStyle style, Locale locale) {
-        return new DateTimeFormatterBuilder().appendText(ERA, style).toFormatter(locale).print(this);
-    }
-
     /**
      * Returns the proleptic year from this era and year of era.
      *
      * @param yearOfEra the year of Era
      * @return the computed prolepticYear