Skip to content

Instantly share code, notes, and snippets.

@jodastephen
Created February 20, 2013 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jodastephen/5000471 to your computer and use it in GitHub Desktop.
Save jodastephen/5000471 to your computer and use it in GitHub Desktop.
APPLIED: EpochMonth patch for #266
# HG changeset patch
# User scolebourne
# Date 1361400915 0
# Node ID 2af8a403982a05882590b6208ba143d1782f29dd
# Parent d468d92a8986851ad83330bafa0f440a53216a6e
Rename EPOCH_MONTH to PROLEPTIC_MONTH
Redefine to be zero year based
Implement in non-ISO calendar systems
See #266
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/LocalDate.java
--- a/src/share/classes/java/time/LocalDate.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/LocalDate.java Wed Feb 20 22:55:15 2013 +0000
@@ -69,9 +69,9 @@
import static java.time.temporal.ChronoField.DAY_OF_MONTH;
import static java.time.temporal.ChronoField.DAY_OF_YEAR;
import static java.time.temporal.ChronoField.EPOCH_DAY;
-import static java.time.temporal.ChronoField.EPOCH_MONTH;
import static java.time.temporal.ChronoField.ERA;
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
import static java.time.temporal.ChronoField.YEAR;
import java.io.DataInput;
@@ -467,7 +467,7 @@
* <li>{@code ALIGNED_WEEK_OF_MONTH}
* <li>{@code ALIGNED_WEEK_OF_YEAR}
* <li>{@code MONTH_OF_YEAR}
- * <li>{@code EPOCH_MONTH}
+ * <li>{@code PROLEPTIC_MONTH}
* <li>{@code YEAR_OF_ERA}
* <li>{@code YEAR}
* <li>{@code ERA}
@@ -538,7 +538,7 @@
* <p>
* If the field is a {@link ChronoField} then the query is implemented here.
* The {@link #isSupported(TemporalField) supported fields} will return valid
- * values based on this date, except {@code EPOCH_DAY} and {@code EPOCH_MONTH}
+ * values based on this date, except {@code EPOCH_DAY} and {@code PROLEPTIC_MONTH}
* which are too large to fit in an {@code int} and throw a {@code DateTimeException}.
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
@@ -588,8 +588,8 @@
if (field == EPOCH_DAY) {
return toEpochDay();
}
- if (field == EPOCH_MONTH) {
- return getEpochMonth();
+ if (field == PROLEPTIC_MONTH) {
+ return getProlepticMonth();
}
return get0(field);
}
@@ -607,7 +607,7 @@
case ALIGNED_WEEK_OF_MONTH: return ((day - 1) / 7) + 1;
case ALIGNED_WEEK_OF_YEAR: return ((getDayOfYear() - 1) / 7) + 1;
case MONTH_OF_YEAR: return month;
- case EPOCH_MONTH: throw new DateTimeException("Field too large for an int: " + field);
+ case PROLEPTIC_MONTH: throw new DateTimeException("Field too large for an int: " + field);
case YEAR_OF_ERA: return (year >= 1 ? year : 1 - year);
case YEAR: return year;
case ERA: return (year >= 1 ? 1 : 0);
@@ -615,8 +615,8 @@
throw new DateTimeException("Unsupported field: " + field.getName());
}
- private long getEpochMonth() {
- return ((year - 1970) * 12L) + (month - 1);
+ private long getProlepticMonth() {
+ return (year * 12L + month - 1);
}
//-----------------------------------------------------------------------
@@ -908,8 +908,8 @@
* The year will be unchanged. The day-of-month will also be unchanged,
* unless it would be invalid for the new month and year. In that case, the
* day-of-month is adjusted to the maximum valid value for the new month and year.
- * <li>{@code EPOCH_MONTH} -
- * Returns a {@code LocalDate} with the specified epoch-month.
+ * <li>{@code PROLEPTIC_MONTH} -
+ * Returns a {@code LocalDate} with the specified proleptic-month.
* The day-of-month will be unchanged, unless it would be invalid for the new month
* and year. In that case, the day-of-month is adjusted to the maximum valid value
* for the new month and year.
@@ -963,7 +963,7 @@
case ALIGNED_WEEK_OF_MONTH: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_MONTH));
case ALIGNED_WEEK_OF_YEAR: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_YEAR));
case MONTH_OF_YEAR: return withMonth((int) newValue);
- case EPOCH_MONTH: return plusMonths(newValue - getLong(EPOCH_MONTH));
+ case PROLEPTIC_MONTH: return plusMonths(newValue - getProlepticMonth());
case YEAR_OF_ERA: return withYear((int) (year >= 1 ? newValue : 1 - newValue));
case YEAR: return withYear((int) newValue);
case ERA: return (getLong(ERA) == newValue ? this : withYear(1 - year));
@@ -1538,8 +1538,8 @@
}
private long monthsUntil(LocalDate end) {
- long packed1 = getEpochMonth() * 32L + getDayOfMonth(); // no overflow
- long packed2 = end.getEpochMonth() * 32L + end.getDayOfMonth(); // no overflow
+ long packed1 = getProlepticMonth() * 32L + getDayOfMonth(); // no overflow
+ long packed2 = end.getProlepticMonth() * 32L + end.getDayOfMonth(); // no overflow
return (packed2 - packed1) / 32;
}
@@ -1580,7 +1580,7 @@
@Override
public Period periodUntil(ChronoLocalDate<?> endDate) {
LocalDate end = LocalDate.from(endDate);
- long totalMonths = end.getEpochMonth() - this.getEpochMonth(); // safe
+ long totalMonths = end.getProlepticMonth() - this.getProlepticMonth(); // safe
int days = end.day - this.day;
if (totalMonths > 0 && days < 0) {
totalMonths--;
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/LocalDateTime.java
--- a/src/share/classes/java/time/LocalDateTime.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/LocalDateTime.java Wed Feb 20 22:55:15 2013 +0000
@@ -546,7 +546,7 @@
* <li>{@code ALIGNED_WEEK_OF_MONTH}
* <li>{@code ALIGNED_WEEK_OF_YEAR}
* <li>{@code MONTH_OF_YEAR}
- * <li>{@code EPOCH_MONTH}
+ * <li>{@code PROLEPTIC_MONTH}
* <li>{@code YEAR_OF_ERA}
* <li>{@code YEAR}
* <li>{@code ERA}
@@ -612,7 +612,7 @@
* If the field is a {@link ChronoField} then the query is implemented here.
* The {@link #isSupported(TemporalField) supported fields} will return valid
* values based on this date-time, except {@code NANO_OF_DAY}, {@code MICRO_OF_DAY},
- * {@code EPOCH_DAY} and {@code EPOCH_MONTH} which are too large to fit in
+ * {@code EPOCH_DAY} and {@code PROLEPTIC_MONTH} which are too large to fit in
* an {@code int} and throw a {@code DateTimeException}.
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/OffsetDateTime.java
--- a/src/share/classes/java/time/OffsetDateTime.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/OffsetDateTime.java Wed Feb 20 22:55:15 2013 +0000
@@ -436,7 +436,7 @@
* <li>{@code ALIGNED_WEEK_OF_MONTH}
* <li>{@code ALIGNED_WEEK_OF_YEAR}
* <li>{@code MONTH_OF_YEAR}
- * <li>{@code EPOCH_MONTH}
+ * <li>{@code PROLEPTIC_MONTH}
* <li>{@code YEAR_OF_ERA}
* <li>{@code YEAR}
* <li>{@code ERA}
@@ -502,7 +502,7 @@
* If the field is a {@link ChronoField} then the query is implemented here.
* The {@link #isSupported(TemporalField) supported fields} will return valid
* values based on this date-time, except {@code NANO_OF_DAY}, {@code MICRO_OF_DAY},
- * {@code EPOCH_DAY}, {@code EPOCH_MONTH} and {@code INSTANT_SECONDS} which are too
+ * {@code EPOCH_DAY}, {@code PROLEPTIC_MONTH} and {@code INSTANT_SECONDS} which are too
* large to fit in an {@code int} and throw a {@code DateTimeException}.
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/YearMonth.java
--- a/src/share/classes/java/time/YearMonth.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/YearMonth.java Wed Feb 20 22:55:15 2013 +0000
@@ -61,9 +61,9 @@
*/
package java.time;
-import static java.time.temporal.ChronoField.EPOCH_MONTH;
import static java.time.temporal.ChronoField.ERA;
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
import static java.time.temporal.ChronoField.YEAR;
import static java.time.temporal.ChronoField.YEAR_OF_ERA;
import static java.time.temporal.ChronoUnit.MONTHS;
@@ -320,7 +320,7 @@
* The supported fields are:
* <ul>
* <li>{@code MONTH_OF_YEAR}
- * <li>{@code EPOCH_MONTH}
+ * <li>{@code PROLEPTIC_MONTH}
* <li>{@code YEAR_OF_ERA}
* <li>{@code YEAR}
* <li>{@code ERA}
@@ -339,7 +339,7 @@
public boolean isSupported(TemporalField field) {
if (field instanceof ChronoField) {
return field == YEAR || field == MONTH_OF_YEAR ||
- field == EPOCH_MONTH || field == YEAR_OF_ERA || field == ERA;
+ field == PROLEPTIC_MONTH || field == YEAR_OF_ERA || field == ERA;
}
return field != null && field.isSupportedBy(this);
}
@@ -384,7 +384,7 @@
* <p>
* If the field is a {@link ChronoField} then the query is implemented here.
* The {@link #isSupported(TemporalField) supported fields} will return valid
- * values based on this year-month, except {@code EPOCH_MONTH} which is too
+ * values based on this year-month, except {@code PROLEPTIC_MONTH} which is too
* large to fit in an {@code int} and throw a {@code DateTimeException}.
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
@@ -430,7 +430,7 @@
if (field instanceof ChronoField) {
switch ((ChronoField) field) {
case MONTH_OF_YEAR: return month;
- case EPOCH_MONTH: return getEpochMonth();
+ case PROLEPTIC_MONTH: return getProlepticMonth();
case YEAR_OF_ERA: return (year < 1 ? 1 - year : year);
case YEAR: return year;
case ERA: return (year < 1 ? 0 : 1);
@@ -440,8 +440,8 @@
return field.getFrom(this);
}
- private long getEpochMonth() {
- return ((year - 1970) * 12L) + (month - 1);
+ private long getProlepticMonth() {
+ return (year * 12L + month - 1);
}
//-----------------------------------------------------------------------
@@ -589,8 +589,8 @@
* <li>{@code MONTH_OF_YEAR} -
* Returns a {@code YearMonth} with the specified month-of-year.
* The year will be unchanged.
- * <li>{@code EPOCH_MONTH} -
- * Returns a {@code YearMonth} with the specified epoch-month.
+ * <li>{@code PROLEPTIC_MONTH} -
+ * Returns a {@code YearMonth} with the specified proleptic-month.
* This completely replaces the year and month of this object.
* <li>{@code YEAR_OF_ERA} -
* Returns a {@code YearMonth} with the specified year-of-era
@@ -628,7 +628,7 @@
f.checkValidValue(newValue);
switch (f) {
case MONTH_OF_YEAR: return withMonth((int) newValue);
- case EPOCH_MONTH: return plusMonths(newValue - getLong(EPOCH_MONTH));
+ case PROLEPTIC_MONTH: return plusMonths(newValue - getProlepticMonth());
case YEAR_OF_ERA: return withYear((int) (year < 1 ? 1 - newValue : newValue));
case YEAR: return withYear((int) newValue);
case ERA: return (getLong(ERA) == newValue ? this : withYear(1 - year));
@@ -908,7 +908,7 @@
* with the year and month changed to be the same as this.
* <p>
* The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)}
- * passing {@link ChronoField#EPOCH_MONTH} as the field.
+ * passing {@link ChronoField#PROLEPTIC_MONTH} as the field.
* If the specified temporal object does not use the ISO calendar system then
* a {@code DateTimeException} is thrown.
* <p>
@@ -932,7 +932,7 @@
if (Chronology.from(temporal).equals(IsoChronology.INSTANCE) == false) {
throw new DateTimeException("Adjustment only supported on ISO date-time");
}
- return temporal.with(EPOCH_MONTH, getEpochMonth());
+ return temporal.with(PROLEPTIC_MONTH, getProlepticMonth());
}
/**
@@ -987,7 +987,7 @@
}
YearMonth end = (YearMonth) endYearMonth;
if (unit instanceof ChronoUnit) {
- long monthsUntil = end.getEpochMonth() - getEpochMonth(); // no overflow
+ long monthsUntil = end.getProlepticMonth() - getProlepticMonth(); // no overflow
switch ((ChronoUnit) unit) {
case MONTHS: return monthsUntil;
case YEARS: return monthsUntil / 12;
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/ZonedDateTime.java
--- a/src/share/classes/java/time/ZonedDateTime.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/ZonedDateTime.java Wed Feb 20 22:55:15 2013 +0000
@@ -663,7 +663,7 @@
* <li>{@code ALIGNED_WEEK_OF_MONTH}
* <li>{@code ALIGNED_WEEK_OF_YEAR}
* <li>{@code MONTH_OF_YEAR}
- * <li>{@code EPOCH_MONTH}
+ * <li>{@code PROLEPTIC_MONTH}
* <li>{@code YEAR_OF_ERA}
* <li>{@code YEAR}
* <li>{@code ERA}
@@ -729,7 +729,7 @@
* If the field is a {@link ChronoField} then the query is implemented here.
* The {@link #isSupported(TemporalField) supported fields} will return valid
* values based on this date-time, except {@code NANO_OF_DAY}, {@code MICRO_OF_DAY},
- * {@code EPOCH_DAY}, {@code EPOCH_MONTH} and {@code INSTANT_SECONDS} which are too
+ * {@code EPOCH_DAY}, {@code PROLEPTIC_MONTH} and {@code INSTANT_SECONDS} which are too
* large to fit in an {@code int} and throw a {@code DateTimeException}.
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/chrono/HijrahDate.java
--- a/src/share/classes/java/time/chrono/HijrahDate.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/chrono/HijrahDate.java Wed Feb 20 22:55:15 2013 +0000
@@ -366,6 +366,7 @@
case ALIGNED_WEEK_OF_MONTH: return ((dayOfMonth - 1) / 7) + 1;
case ALIGNED_WEEK_OF_YEAR: return ((dayOfYear - 1) / 7) + 1;
case MONTH_OF_YEAR: return monthOfYear;
+ case PROLEPTIC_MONTH: return getProlepticMonth();
case YEAR_OF_ERA: return yearOfEra;
case YEAR: return yearOfEra;
case ERA: return era.getValue();
@@ -375,11 +376,16 @@
return field.getFrom(this);
}
+ private long getProlepticMonth() {
+ return yearOfEra * 12L + monthOfYear - 1;
+ }
+
@Override
public HijrahDate with(TemporalField field, long newValue) {
if (field instanceof ChronoField) {
ChronoField f = (ChronoField) field;
- f.checkValidValue(newValue); // TODO: validate value
+ // not using checkValidIntValue so EPOCH_DAY and PROLEPTIC_MONTH work
+ chrono.range(f).checkValidValue(newValue, f); // TODO: validate value
int nvalue = (int) newValue;
switch (f) {
case DAY_OF_WEEK: return plusDays(newValue - dayOfWeek.getValue());
@@ -387,10 +393,11 @@
case ALIGNED_DAY_OF_WEEK_IN_YEAR: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_YEAR));
case DAY_OF_MONTH: return resolvePreviousValid(yearOfEra, monthOfYear, nvalue);
case DAY_OF_YEAR: return resolvePreviousValid(yearOfEra, ((nvalue - 1) / 30) + 1, ((nvalue - 1) % 30) + 1);
- case EPOCH_DAY: return new HijrahDate(chrono, nvalue);
+ case EPOCH_DAY: return new HijrahDate(chrono, newValue);
case ALIGNED_WEEK_OF_MONTH: return plusDays((newValue - getLong(ALIGNED_WEEK_OF_MONTH)) * 7);
case ALIGNED_WEEK_OF_YEAR: return plusDays((newValue - getLong(ALIGNED_WEEK_OF_YEAR)) * 7);
case MONTH_OF_YEAR: return resolvePreviousValid(yearOfEra, nvalue, dayOfMonth);
+ case PROLEPTIC_MONTH: return plusMonths(newValue - getProlepticMonth());
case YEAR_OF_ERA: return resolvePreviousValid(yearOfEra >= 1 ? nvalue : 1 - nvalue, monthOfYear, dayOfMonth);
case YEAR: return resolvePreviousValid(nvalue, monthOfYear, dayOfMonth);
case ERA: return resolvePreviousValid(1 - yearOfEra, monthOfYear, dayOfMonth);
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/chrono/JapaneseChronology.java
--- a/src/share/classes/java/time/chrono/JapaneseChronology.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/chrono/JapaneseChronology.java Wed Feb 20 22:55:15 2013 +0000
@@ -325,8 +325,7 @@
case NANO_OF_SECOND:
case CLOCK_HOUR_OF_DAY:
case CLOCK_HOUR_OF_AMPM:
- case EPOCH_DAY:
- case EPOCH_MONTH:
+ case EPOCH_DAY: // TODO: if year is restricted, then so is epoch-day
return field.range();
}
Calendar jcal = Calendar.getInstance(LOCALE);
@@ -337,8 +336,13 @@
jcal.getMaximum(Calendar.ERA) - JapaneseEra.ERA_OFFSET);
case YEAR:
case YEAR_OF_ERA:
+ // TODO: this is not right
return ValueRange.of(Year.MIN_VALUE, jcal.getGreatestMinimum(Calendar.YEAR),
jcal.getLeastMaximum(Calendar.YEAR), Year.MAX_VALUE);
+ case PROLEPTIC_MONTH:
+ // TODO: should be the range of months bound by the valid range of years
+ return ValueRange.of((jcal.getGreatestMinimum(Calendar.YEAR) - 1) * 12,
+ (jcal.getLeastMaximum(Calendar.YEAR)) * 12);
case MONTH_OF_YEAR:
return ValueRange.of(jcal.getMinimum(Calendar.MONTH) + 1, jcal.getGreatestMinimum(Calendar.MONTH) + 1,
jcal.getLeastMaximum(Calendar.MONTH) + 1, jcal.getMaximum(Calendar.MONTH) + 1);
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/chrono/JapaneseDate.java
--- a/src/share/classes/java/time/chrono/JapaneseDate.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/chrono/JapaneseDate.java Wed Feb 20 22:55:15 2013 +0000
@@ -356,6 +356,7 @@
return JapaneseChronology.JCAL.getDayOfYear(jdate);
}
}
+ // YEAR and PROLEPTIC_MONTH are same as ISO
// TODO: review other fields
return isoDate.getLong(field);
}
@@ -392,8 +393,7 @@
case YEAR_OF_ERA:
case YEAR:
case ERA: {
- f.checkValidValue(newValue);
- int nvalue = (int) newValue;
+ int nvalue = getChronology().range(f).checkValidIntValue(newValue, f);
switch (f) {
case YEAR_OF_ERA:
return this.withYear(nvalue);
@@ -405,6 +405,7 @@
}
}
}
+ // YEAR, PROLEPTIC_MONTH and others are same as ISO
// TODO: review other fields, such as WEEK_OF_YEAR
return with(isoDate.with(field, newValue));
}
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/chrono/MinguoChronology.java
--- a/src/share/classes/java/time/chrono/MinguoChronology.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/chrono/MinguoChronology.java Wed Feb 20 22:55:15 2013 +0000
@@ -56,6 +56,7 @@
*/
package java.time.chrono;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
import static java.time.temporal.ChronoField.YEAR;
import java.io.Serializable;
@@ -269,6 +270,10 @@
@Override
public ValueRange range(ChronoField field) {
switch (field) {
+ case PROLEPTIC_MONTH: {
+ ValueRange range = PROLEPTIC_MONTH.range();
+ return ValueRange.of(range.getMinimum() - YEARS_DIFFERENCE * 12L, range.getMaximum() - YEARS_DIFFERENCE * 12L);
+ }
case YEAR_OF_ERA: {
ValueRange range = YEAR.range();
return ValueRange.of(1, range.getMaximum() - YEARS_DIFFERENCE, -range.getMinimum() + 1 + YEARS_DIFFERENCE);
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/chrono/MinguoDate.java
--- a/src/share/classes/java/time/chrono/MinguoDate.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/chrono/MinguoDate.java Wed Feb 20 22:55:15 2013 +0000
@@ -242,6 +242,8 @@
public long getLong(TemporalField field) {
if (field instanceof ChronoField) {
switch ((ChronoField) field) {
+ case PROLEPTIC_MONTH:
+ return getProlepticMonth();
case YEAR_OF_ERA: {
int prolepticYear = getProlepticYear();
return (prolepticYear >= 1 ? prolepticYear : 1 - prolepticYear);
@@ -256,6 +258,10 @@
return field.getFrom(this);
}
+ private long getProlepticMonth() {
+ return getProlepticYear() * 12L + isoDate.getMonthValue() - 1;
+ }
+
private int getProlepticYear() {
return isoDate.getYear() - YEARS_DIFFERENCE;
}
@@ -269,11 +275,13 @@
return this;
}
switch (f) {
+ case PROLEPTIC_MONTH:
+ getChronology().range(f).checkValidValue(newValue, f);
+ return plusMonths(newValue - getProlepticMonth());
case YEAR_OF_ERA:
case YEAR:
case ERA: {
- f.checkValidValue(newValue);
- int nvalue = (int) newValue;
+ int nvalue = getChronology().range(f).checkValidIntValue(newValue, f);
switch (f) {
case YEAR_OF_ERA:
return with(isoDate.withYear(getProlepticYear() >= 1 ? nvalue + YEARS_DIFFERENCE : (1 - nvalue) + YEARS_DIFFERENCE));
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/chrono/ThaiBuddhistChronology.java
--- a/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java Wed Feb 20 22:55:15 2013 +0000
@@ -56,6 +56,7 @@
*/
package java.time.chrono;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
import static java.time.temporal.ChronoField.YEAR;
import java.io.Serializable;
@@ -304,6 +305,10 @@
@Override
public ValueRange range(ChronoField field) {
switch (field) {
+ case PROLEPTIC_MONTH: {
+ ValueRange range = PROLEPTIC_MONTH.range();
+ return ValueRange.of(range.getMinimum() + YEARS_DIFFERENCE * 12L, range.getMaximum() + YEARS_DIFFERENCE * 12L);
+ }
case YEAR_OF_ERA: {
ValueRange range = YEAR.range();
return ValueRange.of(1, -(range.getMinimum() + YEARS_DIFFERENCE) + 1, range.getMaximum() + YEARS_DIFFERENCE);
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/chrono/ThaiBuddhistDate.java
--- a/src/share/classes/java/time/chrono/ThaiBuddhistDate.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/chrono/ThaiBuddhistDate.java Wed Feb 20 22:55:15 2013 +0000
@@ -242,6 +242,8 @@
public long getLong(TemporalField field) {
if (field instanceof ChronoField) {
switch ((ChronoField) field) {
+ case PROLEPTIC_MONTH:
+ return getProlepticMonth();
case YEAR_OF_ERA: {
int prolepticYear = getProlepticYear();
return (prolepticYear >= 1 ? prolepticYear : 1 - prolepticYear);
@@ -256,6 +258,10 @@
return field.getFrom(this);
}
+ private long getProlepticMonth() {
+ return getProlepticYear() * 12L + isoDate.getMonthValue() - 1;
+ }
+
private int getProlepticYear() {
return isoDate.getYear() + YEARS_DIFFERENCE;
}
@@ -269,11 +275,13 @@
return this;
}
switch (f) {
+ case PROLEPTIC_MONTH:
+ getChronology().range(f).checkValidValue(newValue, f);
+ return plusMonths(newValue - getProlepticMonth());
case YEAR_OF_ERA:
case YEAR:
case ERA: {
- f.checkValidValue(newValue);
- int nvalue = (int) newValue;
+ int nvalue = getChronology().range(f).checkValidIntValue(newValue, f);
switch (f) {
case YEAR_OF_ERA:
return with(isoDate.withYear((getProlepticYear() >= 1 ? nvalue : 1 - nvalue) - YEARS_DIFFERENCE));
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/format/DateTimeBuilder.java
--- a/src/share/classes/java/time/format/DateTimeBuilder.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/format/DateTimeBuilder.java Wed Feb 20 22:55:15 2013 +0000
@@ -73,8 +73,6 @@
import static java.time.temporal.ChronoField.DAY_OF_WEEK;
import static java.time.temporal.ChronoField.DAY_OF_YEAR;
import static java.time.temporal.ChronoField.EPOCH_DAY;
-import static java.time.temporal.ChronoField.EPOCH_MONTH;
-import static java.time.temporal.ChronoField.ERA;
import static java.time.temporal.ChronoField.HOUR_OF_AMPM;
import static java.time.temporal.ChronoField.HOUR_OF_DAY;
import static java.time.temporal.ChronoField.MICRO_OF_DAY;
@@ -86,10 +84,10 @@
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
import static java.time.temporal.ChronoField.NANO_OF_DAY;
import static java.time.temporal.ChronoField.NANO_OF_SECOND;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
import static java.time.temporal.ChronoField.SECOND_OF_DAY;
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
import static java.time.temporal.ChronoField.YEAR;
-import static java.time.temporal.ChronoField.YEAR_OF_ERA;
import java.time.DateTimeException;
import java.time.DayOfWeek;
@@ -256,17 +254,17 @@
if (chrono == IsoChronology.INSTANCE) {
// normalize fields
- if (standardFields.containsKey(EPOCH_MONTH)) {
- long em = standardFields.remove(EPOCH_MONTH);
- addFieldValue(MONTH_OF_YEAR, (em % 12) + 1);
- addFieldValue(YEAR, (em / 12) + 1970);
+ if (standardFields.containsKey(PROLEPTIC_MONTH)) {
+ long em = standardFields.remove(PROLEPTIC_MONTH);
+ addFieldValue(MONTH_OF_YEAR, Math.floorMod(em, 12) + 1);
+ addFieldValue(YEAR, Math.floorDiv(em, 12));
}
} else {
- // TODO: revisit EPOCH_MONTH calculation in non-ISO chronology
- // Handle EPOCH_MONTH here for non-ISO Chronology
- if (standardFields.containsKey(EPOCH_MONTH)) {
- long em = standardFields.remove(EPOCH_MONTH);
- ChronoLocalDate<?> chronoDate = chrono.date(LocalDate.ofEpochDay(0L));
+ // TODO: revisit PROLEPTIC_MONTH calculation in non-ISO chronology
+ // Handle PROLEPTIC_MONTH here for non-ISO Chronology
+ if (standardFields.containsKey(PROLEPTIC_MONTH)) {
+ long em = standardFields.remove(PROLEPTIC_MONTH);
+ ChronoLocalDate<?> chronoDate = chrono.date(1, 1, 1);
chronoDate = chronoDate.plus(em, ChronoUnit.MONTHS);
LocalDate date = LocalDate.ofEpochDay(chronoDate.toEpochDay());
checkDate(date);
diff -r d468d92a8986 -r 2af8a403982a src/share/classes/java/time/temporal/ChronoField.java
--- a/src/share/classes/java/time/temporal/ChronoField.java Tue Feb 19 15:51:43 2013 +0000
+++ b/src/share/classes/java/time/temporal/ChronoField.java Wed Feb 20 22:55:15 2013 +0000
@@ -380,15 +380,25 @@
*/
MONTH_OF_YEAR("MonthOfYear", MONTHS, YEARS, ValueRange.of(1, 12)),
/**
- * The epoch-month based on the Java epoch of 1970-01-01.
+ * The proleptic-month based, counting months sequentially from year 0.
* <p>
- * This field is the sequential count of months where January 1970 (ISO) is zero.
+ * This field is the sequential count of months where the first month
+ * in proleptic-year zero has the value zero.
+ * Later months have increasingly larger values.
+ * Earlier months have increasingly small values.
+ * There are no gaps or breaks in the sequence of months.
* Note that this uses the <i>local</i> time-line, ignoring offset and time-zone.
* <p>
- * Non-ISO calendar systems should also implement this field to represent a sequential
- * count of months. It is recommended to define zero as the month of 1970-01-01 (ISO).
+ * In the default ISO calendar system, June 2012 would have the value
+ * {@code (2012 * 12 + 6 - 1)}. This field is primarily for internal use.
+ * <p>
+ * Non-ISO calendar systems must implement this field as per the definition above.
+ * It is just a simple zero-based count of elapsed months from the start of proleptic-year 0.
+ * All calendar systems with a full proleptic-year definition will have a year zero.
+ * If the calendar system has a minimum year that excludes year zero, then one must
+ * be extrapolated in order for this method to be defined.
*/
- EPOCH_MONTH("EpochMonth", MONTHS, FOREVER, ValueRange.of((Year.MIN_VALUE - 1970L) * 12, (Year.MAX_VALUE - 1970L) * 12L - 1L)),
+ PROLEPTIC_MONTH("ProlepticMonth", MONTHS, FOREVER, ValueRange.of(Year.MIN_VALUE * 12L, Year.MAX_VALUE * 12L + 11)),
/**
* The year within the era.
* <p>
diff -r d468d92a8986 -r 2af8a403982a test/java/time/tck/java/time/TCKLocalDate.java
--- a/test/java/time/tck/java/time/TCKLocalDate.java Tue Feb 19 15:51:43 2013 +0000
+++ b/test/java/time/tck/java/time/TCKLocalDate.java Wed Feb 20 22:55:15 2013 +0000
@@ -67,9 +67,9 @@
import static java.time.temporal.ChronoField.DAY_OF_WEEK;
import static java.time.temporal.ChronoField.DAY_OF_YEAR;
import static java.time.temporal.ChronoField.EPOCH_DAY;
-import static java.time.temporal.ChronoField.EPOCH_MONTH;
import static java.time.temporal.ChronoField.ERA;
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
import static java.time.temporal.ChronoField.YEAR;
import static java.time.temporal.ChronoField.YEAR_OF_ERA;
import static org.testng.Assert.assertEquals;
@@ -170,7 +170,7 @@
ALIGNED_WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
MONTH_OF_YEAR,
- EPOCH_MONTH,
+ PROLEPTIC_MONTH,
YEAR_OF_ERA,
YEAR,
ERA,
@@ -617,21 +617,26 @@
@Test
public void test_get_TemporalField() {
LocalDate test = LocalDate.of(2008, 6, 30);
- assertEquals(test.get(ChronoField.YEAR), 2008);
- assertEquals(test.get(ChronoField.MONTH_OF_YEAR), 6);
- assertEquals(test.get(ChronoField.DAY_OF_MONTH), 30);
- assertEquals(test.get(ChronoField.DAY_OF_WEEK), 1);
- assertEquals(test.get(ChronoField.DAY_OF_YEAR), 182);
+ assertEquals(test.get(YEAR), 2008);
+ assertEquals(test.get(MONTH_OF_YEAR), 6);
+ assertEquals(test.get(YEAR_OF_ERA), 2008);
+ assertEquals(test.get(ERA), 1);
+ assertEquals(test.get(DAY_OF_MONTH), 30);
+ assertEquals(test.get(DAY_OF_WEEK), 1);
+ assertEquals(test.get(DAY_OF_YEAR), 182);
}
@Test
public void test_getLong_TemporalField() {
LocalDate test = LocalDate.of(2008, 6, 30);
- assertEquals(test.getLong(ChronoField.YEAR), 2008);
- assertEquals(test.getLong(ChronoField.MONTH_OF_YEAR), 6);
- assertEquals(test.getLong(ChronoField.DAY_OF_MONTH), 30);
- assertEquals(test.getLong(ChronoField.DAY_OF_WEEK), 1);
- assertEquals(test.getLong(ChronoField.DAY_OF_YEAR), 182);
+ assertEquals(test.getLong(YEAR), 2008);
+ assertEquals(test.getLong(MONTH_OF_YEAR), 6);
+ assertEquals(test.getLong(YEAR_OF_ERA), 2008);
+ assertEquals(test.getLong(ERA), 1);
+ assertEquals(test.getLong(PROLEPTIC_MONTH), 2008 * 12 + 6 - 1);
+ assertEquals(test.getLong(DAY_OF_MONTH), 30);
+ assertEquals(test.getLong(DAY_OF_WEEK), 1);
+ assertEquals(test.getLong(DAY_OF_YEAR), 182);
}
//-----------------------------------------------------------------------
diff -r d468d92a8986 -r 2af8a403982a test/java/time/tck/java/time/TCKLocalDateTime.java
--- a/test/java/time/tck/java/time/TCKLocalDateTime.java Tue Feb 19 15:51:43 2013 +0000
+++ b/test/java/time/tck/java/time/TCKLocalDateTime.java Wed Feb 20 22:55:15 2013 +0000
@@ -70,7 +70,6 @@
import static java.time.temporal.ChronoField.DAY_OF_WEEK;
import static java.time.temporal.ChronoField.DAY_OF_YEAR;
import static java.time.temporal.ChronoField.EPOCH_DAY;
-import static java.time.temporal.ChronoField.EPOCH_MONTH;
import static java.time.temporal.ChronoField.ERA;
import static java.time.temporal.ChronoField.HOUR_OF_AMPM;
import static java.time.temporal.ChronoField.HOUR_OF_DAY;
@@ -83,6 +82,7 @@
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
import static java.time.temporal.ChronoField.NANO_OF_DAY;
import static java.time.temporal.ChronoField.NANO_OF_SECOND;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
import static java.time.temporal.ChronoField.SECOND_OF_DAY;
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
import static java.time.temporal.ChronoField.YEAR;
@@ -195,7 +195,7 @@
ALIGNED_WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
MONTH_OF_YEAR,
- EPOCH_MONTH,
+ PROLEPTIC_MONTH,
YEAR_OF_ERA,
YEAR,
ERA,
diff -r d468d92a8986 -r 2af8a403982a test/java/time/tck/java/time/TCKOffsetDateTime.java
--- a/test/java/time/tck/java/time/TCKOffsetDateTime.java Tue Feb 19 15:51:43 2013 +0000
+++ b/test/java/time/tck/java/time/TCKOffsetDateTime.java Wed Feb 20 22:55:15 2013 +0000
@@ -71,7 +71,6 @@
import static java.time.temporal.ChronoField.DAY_OF_WEEK;
import static java.time.temporal.ChronoField.DAY_OF_YEAR;
import static java.time.temporal.ChronoField.EPOCH_DAY;
-import static java.time.temporal.ChronoField.EPOCH_MONTH;
import static java.time.temporal.ChronoField.ERA;
import static java.time.temporal.ChronoField.HOUR_OF_AMPM;
import static java.time.temporal.ChronoField.HOUR_OF_DAY;
@@ -86,6 +85,7 @@
import static java.time.temporal.ChronoField.NANO_OF_DAY;
import static java.time.temporal.ChronoField.NANO_OF_SECOND;
import static java.time.temporal.ChronoField.OFFSET_SECONDS;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
import static java.time.temporal.ChronoField.SECOND_OF_DAY;
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
import static java.time.temporal.ChronoField.YEAR;
@@ -188,7 +188,7 @@
ALIGNED_WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
MONTH_OF_YEAR,
- EPOCH_MONTH,
+ PROLEPTIC_MONTH,
YEAR_OF_ERA,
YEAR,
ERA,
diff -r d468d92a8986 -r 2af8a403982a test/java/time/tck/java/time/TCKYearMonth.java
--- a/test/java/time/tck/java/time/TCKYearMonth.java Tue Feb 19 15:51:43 2013 +0000
+++ b/test/java/time/tck/java/time/TCKYearMonth.java Wed Feb 20 22:55:15 2013 +0000
@@ -59,9 +59,9 @@
*/
package tck.java.time;
-import static java.time.temporal.ChronoField.EPOCH_MONTH;
import static java.time.temporal.ChronoField.ERA;
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
import static java.time.temporal.ChronoField.YEAR;
import static java.time.temporal.ChronoField.YEAR_OF_ERA;
import static org.testng.Assert.assertEquals;
@@ -126,7 +126,7 @@
protected List<TemporalField> validFields() {
TemporalField[] array = {
MONTH_OF_YEAR,
- EPOCH_MONTH,
+ PROLEPTIC_MONTH,
YEAR_OF_ERA,
YEAR,
ERA,
@@ -400,19 +400,19 @@
//-----------------------------------------------------------------------
@Test
public void test_get_TemporalField() {
- assertEquals(TEST_2008_06.get(ChronoField.YEAR), 2008);
- assertEquals(TEST_2008_06.get(ChronoField.MONTH_OF_YEAR), 6);
- assertEquals(TEST_2008_06.get(ChronoField.YEAR_OF_ERA), 2008);
- assertEquals(TEST_2008_06.get(ChronoField.ERA), 1);
+ assertEquals(TEST_2008_06.get(YEAR), 2008);
+ assertEquals(TEST_2008_06.get(MONTH_OF_YEAR), 6);
+ assertEquals(TEST_2008_06.get(YEAR_OF_ERA), 2008);
+ assertEquals(TEST_2008_06.get(ERA), 1);
}
@Test
public void test_getLong_TemporalField() {
- assertEquals(TEST_2008_06.getLong(ChronoField.YEAR), 2008);
- assertEquals(TEST_2008_06.getLong(ChronoField.MONTH_OF_YEAR), 6);
- assertEquals(TEST_2008_06.getLong(ChronoField.YEAR_OF_ERA), 2008);
- assertEquals(TEST_2008_06.getLong(ChronoField.ERA), 1);
- assertEquals(TEST_2008_06.getLong(ChronoField.EPOCH_MONTH), (2008 - 1970) * 12 + 6 - 1);
+ assertEquals(TEST_2008_06.getLong(YEAR), 2008);
+ assertEquals(TEST_2008_06.getLong(MONTH_OF_YEAR), 6);
+ assertEquals(TEST_2008_06.getLong(YEAR_OF_ERA), 2008);
+ assertEquals(TEST_2008_06.getLong(ERA), 1);
+ assertEquals(TEST_2008_06.getLong(PROLEPTIC_MONTH), 2008 * 12 + 6 -1);
}
//-----------------------------------------------------------------------
diff -r d468d92a8986 -r 2af8a403982a test/java/time/tck/java/time/TCKZonedDateTime.java
--- a/test/java/time/tck/java/time/TCKZonedDateTime.java Tue Feb 19 15:51:43 2013 +0000
+++ b/test/java/time/tck/java/time/TCKZonedDateTime.java Wed Feb 20 22:55:15 2013 +0000
@@ -73,7 +73,6 @@
import static java.time.temporal.ChronoField.DAY_OF_WEEK;
import static java.time.temporal.ChronoField.DAY_OF_YEAR;
import static java.time.temporal.ChronoField.EPOCH_DAY;
-import static java.time.temporal.ChronoField.EPOCH_MONTH;
import static java.time.temporal.ChronoField.ERA;
import static java.time.temporal.ChronoField.HOUR_OF_AMPM;
import static java.time.temporal.ChronoField.HOUR_OF_DAY;
@@ -88,6 +87,7 @@
import static java.time.temporal.ChronoField.NANO_OF_DAY;
import static java.time.temporal.ChronoField.NANO_OF_SECOND;
import static java.time.temporal.ChronoField.OFFSET_SECONDS;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
import static java.time.temporal.ChronoField.SECOND_OF_DAY;
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
import static java.time.temporal.ChronoField.YEAR;
@@ -196,7 +196,7 @@
ALIGNED_WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
MONTH_OF_YEAR,
- EPOCH_MONTH,
+ PROLEPTIC_MONTH,
YEAR_OF_ERA,
YEAR,
ERA,
diff -r d468d92a8986 -r 2af8a403982a test/java/time/tck/java/time/chrono/CopticChronology.java
--- a/test/java/time/tck/java/time/chrono/CopticChronology.java Tue Feb 19 15:51:43 2013 +0000
+++ b/test/java/time/tck/java/time/chrono/CopticChronology.java Wed Feb 20 22:55:15 2013 +0000
@@ -241,7 +241,7 @@
case DAY_OF_MONTH: return ValueRange.of(1, 5, 30);
case ALIGNED_WEEK_OF_MONTH: return ValueRange.of(1, 1, 5);
case MONTH_OF_YEAR: return ValueRange.of(1, 13);
- case EPOCH_MONTH: return ValueRange.of(-1000, 1000); // TODO
+ case PROLEPTIC_MONTH: return ValueRange.of(-1000, 1000); // TODO
case YEAR_OF_ERA: return ValueRange.of(1, 999, 1000); // TODO
case YEAR: return ValueRange.of(-1000, 1000); // TODO
}
diff -r d468d92a8986 -r 2af8a403982a test/java/time/tck/java/time/chrono/TestJapaneseChronology.java
--- a/test/java/time/tck/java/time/chrono/TestJapaneseChronology.java Tue Feb 19 15:51:43 2013 +0000
+++ b/test/java/time/tck/java/time/chrono/TestJapaneseChronology.java Wed Feb 20 22:55:15 2013 +0000
@@ -56,10 +56,15 @@
*/
package tck.java.time.chrono;
+import static java.time.temporal.ChronoField.DAY_OF_MONTH;
+import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
+import static java.time.temporal.ChronoField.YEAR;
+import static java.time.temporal.ChronoField.YEAR_OF_ERA;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
+import static java.time.temporal.ChronoField.ERA;
import java.util.List;
@@ -269,6 +274,41 @@
}
//-----------------------------------------------------------------------
+ // get(TemporalField)
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_getLong() {
+ JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_SHOWA, 63, 6, 30);
+ assertEquals(base.getLong(ERA), JapaneseChronology.ERA_SHOWA.getValue());
+ assertEquals(base.getLong(YEAR), 1988L);
+ assertEquals(base.getLong(YEAR_OF_ERA), 63L);
+ assertEquals(base.getLong(MONTH_OF_YEAR), 6L);
+ assertEquals(base.getLong(DAY_OF_MONTH), 30L);
+ }
+
+ //-----------------------------------------------------------------------
+ // with(TemporalField, long)
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_with_TemporalField_long() {
+ JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_SHOWA, 63, 6, 30);
+ JapaneseDate test = base.with(YEAR, 1987);
+ assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_SHOWA, 62, 6, 30));
+
+ test = test.with(YEAR_OF_ERA, 2);
+ assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_SHOWA, 2, 6, 30));
+
+ test = test.with(ERA, JapaneseChronology.ERA_HEISEI.getValue());
+ assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_HEISEI, 2, 6, 30));
+
+ test = test.with(MONTH_OF_YEAR, 3);
+ assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_HEISEI, 2, 3, 30));
+
+ test = test.with(DAY_OF_MONTH, 4);
+ assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_HEISEI, 2, 3, 4));
+ }
+
+ //-----------------------------------------------------------------------
// with(WithAdjuster)
//-----------------------------------------------------------------------
@Test(groups={"tck"})
diff -r d468d92a8986 -r 2af8a403982a test/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java
--- a/test/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java Tue Feb 19 15:51:43 2013 +0000
+++ b/test/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java Wed Feb 20 22:55:15 2013 +0000
@@ -67,8 +67,8 @@
import static java.time.temporal.ChronoField.DAY_OF_WEEK;
import static java.time.temporal.ChronoField.DAY_OF_YEAR;
import static java.time.temporal.ChronoField.EPOCH_DAY;
-import static java.time.temporal.ChronoField.EPOCH_MONTH;
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
import static java.time.temporal.ChronoField.YEAR;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
@@ -92,7 +92,7 @@
Object[][] data_combine() {
return new Object[][] {
{YEAR, 2012, MONTH_OF_YEAR, 6, DAY_OF_MONTH, 3, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)},
- {EPOCH_MONTH, (2012 - 1970) * 12 + 6 - 1, DAY_OF_MONTH, 3, null, null, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)},
+ {PROLEPTIC_MONTH, 2012 * 12 + 6 - 1, DAY_OF_MONTH, 3, null, null, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)},
{YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 6, DAY_OF_WEEK, 3, null, null, LocalDate.class, LocalDate.of(2012, 2, 8)},
{YEAR, 2012, DAY_OF_YEAR, 155, null, null, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)},
// {ERA, 1, YEAR_OF_ERA, 2012, DAY_OF_YEAR, 155, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)},
@@ -176,9 +176,9 @@
{ALIGNED_DAY_OF_WEEK_IN_YEAR, 4, ALIGNED_DAY_OF_WEEK_IN_YEAR, 4L},
{ALIGNED_WEEK_OF_MONTH, 4, ALIGNED_WEEK_OF_MONTH, 4},
{ALIGNED_DAY_OF_WEEK_IN_MONTH, 3, ALIGNED_DAY_OF_WEEK_IN_MONTH, 3},
- {EPOCH_MONTH, 15, EPOCH_MONTH, null},
- {EPOCH_MONTH, 15, YEAR, 1971},
- {EPOCH_MONTH, 15, MONTH_OF_YEAR, 4},
+ {PROLEPTIC_MONTH, 27, PROLEPTIC_MONTH, null},
+ {PROLEPTIC_MONTH, 27, YEAR, 2},
+ {PROLEPTIC_MONTH, 27, MONTH_OF_YEAR, 4},
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment