src/share/classes/java/time/chrono/MinguoEra.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 Minguo calendar system.
  * <p>
  * The Minguo 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 MinguoEra implements Era<MinguoChrono>  {
+enum MinguoEra implements Era  {
 
     /**
      * The singleton instance for the era BEFORE_ROC, 'Before Republic of China'.
      * This has the numeric value of {@code 0}.
      */

@@ -133,76 +122,27 @@
     public int getValue() {
         return ordinal();
     }
 
     @Override
-    public MinguoChrono getChrono() {
-        return MinguoChrono.INSTANCE;
+    public MinguoChronology getChronology() {
+        return MinguoChronology.INSTANCE;
     }
 
     // JDK8 default methods:
     //-----------------------------------------------------------------------
     @Override
-    public ChronoLocalDate<MinguoChrono> date(int year, int month, int day) {
-        return getChrono().date(this, year, month, day);
-    }
-
-    @Override
-    public ChronoLocalDate<MinguoChrono> 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);
+    public MinguoDate date(int year, int month, int day) {
+        return (MinguoDate)(getChronology().date(this, year, month, day));
     }
 
     @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 MinguoDate dateYearDay(int year, int dayOfYear) {
+        return (MinguoDate)(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);
-    }
-
-    //-----------------------------------------------------------------------
     private Object writeReplace() {
         return new Ser(Ser.MINGUO_ERA_TYPE, this);
     }
 
     void writeExternal(DataOutput out) throws IOException {