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

Print this page

        

@@ -52,27 +52,17 @@
  * 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 static java.time.temporal.ChronoField.ERA;
 
 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 Thai Buddhist calendar system.
  * <p>
  * The Thai Buddhist calendar system has two eras.

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

@@ -132,73 +122,24 @@
     public int getValue() {
         return ordinal();
     }
 
     @Override
-    public ThaiBuddhistChrono getChrono() {
-        return ThaiBuddhistChrono.INSTANCE;
+    public ThaiBuddhistChronology getChronology() {
+        return ThaiBuddhistChronology.INSTANCE;
     }
 
     // JDK8 default methods:
     //-----------------------------------------------------------------------
     @Override
-    public ChronoLocalDate<ThaiBuddhistChrono> date(int year, int month, int day) {
-        return getChrono().date(this, year, month, day);
+    public ThaiBuddhistDate date(int year, int month, int day) {
+        return (ThaiBuddhistDate)(getChronology().date(this, year, month, day));
     }
 
     @Override
-    public ChronoLocalDate<ThaiBuddhistChrono> 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);
-    }
-
-    //-------------------------------------------------------------------------
-    @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);
+    public ThaiBuddhistDate dateYearDay(int year, int dayOfYear) {
+        return (ThaiBuddhistDate)(getChronology().dateYearDay(this, year, dayOfYear));
     }
 
     //-----------------------------------------------------------------------
     private Object writeReplace() {
         return new Ser(Ser.THAIBUDDHIST_ERA_TYPE, this);