diff --git a/time4j-android/src/main/java/net/time4j/history/ChronoHistory.java b/time4j-android/src/main/java/net/time4j/history/ChronoHistory.java index 6c48064..43f8d01 100644 --- a/time4j-android/src/main/java/net/time4j/history/ChronoHistory.java +++ b/time4j-android/src/main/java/net/time4j/history/ChronoHistory.java @@ -1854,7 +1854,7 @@ private boolean isOutOfRange(HistoricDate hd) { } else if (this == PROLEPTIC_JULIAN) { return (Math.abs(ad) > JULIAN_YMAX); } else if (this == PROLEPTIC_GREGORIAN) { - return false; + return (Math.abs(ad) > GregorianMath.MAX_YEAR); } else { return ((ad < -44) || (ad > 9999)); } diff --git a/time4j-android/src/main/java/net/time4j/history/HistoricDate.java b/time4j-android/src/main/java/net/time4j/history/HistoricDate.java index a2db88b..963faba 100644 --- a/time4j-android/src/main/java/net/time4j/history/HistoricDate.java +++ b/time4j-android/src/main/java/net/time4j/history/HistoricDate.java @@ -84,7 +84,7 @@ public final class HistoricDate * YearDefinition.DUAL_DATING, NewYearRule.BEGIN_OF_JANUARY.until(Integer.MAX_VALUE))}.
* * @param era historic era - * @param yearOfEra year of related era ({@code 1 <= yearOfEra <= 999,999,999}) starting on January the first + * @param yearOfEra year of related era ({@code 1 <= yearOfEra}) starting on January the first * @param month historic month (1-12) * @param dom historic day of month (1-31) * @return new historic date (not yet validated) @@ -97,7 +97,7 @@ public final class HistoricDate * YearDefinition.DUAL_DATING, NewYearRule.BEGIN_OF_JANUARY.until(Integer.MAX_VALUE))}. * * @param era historic era - * @param yearOfEra year of related era ({@code 1 <= yearOfEra <= 999,999,999}) starting on January the first + * @param yearOfEra year of related era ({@code 1 <= yearOfEra}) starting on January the first * @param month historic month (1-12) * @param dom historic day of month (1-31) * @return new historic date (not yet validated) @@ -120,12 +120,10 @@ public static HistoricDate of( *Constructs a new tuple of given historic chronological components.
* *Note: A detailed validation is not done. Such a validation is the responsibility - * of any {@code ChronoHistory}, however. The parameter year-of-era must not have - * more than 9 digits.
+ * of any {@code ChronoHistory}, however. * * @param era historic era - * @param yearOfEra year of era which will be interpreted according to given year definition, - * usually ({@code 1 <= yearOfEra <= 999,999,999}) + * @param yearOfEra positive year of era which will be interpreted according to given year definition * @param month historic month (1-12) * @param dom historic day of month (1-31) * @param yearDefinition defines a strategy how to interprete year of era @@ -139,11 +137,10 @@ public static HistoricDate of( *Konstruiert ein neues Tupel aus den angegebenen historischen Zeitkomponenten.
* *Hinweis: Eine detaillierte Validierung wird nicht gemacht. Das ist stattdessen Aufgabe - * der {@code ChronoHistory}. Der Parameter year-of-era darf nicht mehr als 9 Ziffern haben.
+ * der {@code ChronoHistory}. * * @param era historic era - * @param yearOfEra year of era which will be interpreted according to given year definition, - * usually ({@code 1 <= yearOfEra <= 999,999,999}) + * @param yearOfEra positive year of era which will be interpreted according to given year definition * @param month historic month (1-12) * @param dom historic day of month (1-31) * @param yearDefinition defines a strategy how to interprete year of era @@ -180,12 +177,6 @@ public static HistoricDate of( "Year of era must be positive: " + toString(era, yearOfEra, month, dom)); } - if (yearOfEra > 999999999) { - throw new IllegalArgumentException( - "Year of era must not have more than 9 digits: " - + toString(era, yearOfEra, month, dom)); - } - if (!yearDefinition.equals(YearDefinition.DUAL_DATING)) { // here we interprete yearOfEra as yearOfDisplay and have to translate it to standard calendar year NewYearRule rule = newYearStrategy.rule(era, yearOfEra); diff --git a/time4j-android/src/main/java/net/time4j/history/HistoricDateElement.java b/time4j-android/src/main/java/net/time4j/history/HistoricDateElement.java index f1c0d9a..3a66110 100644 --- a/time4j-android/src/main/java/net/time4j/history/HistoricDateElement.java +++ b/time4j-android/src/main/java/net/time4j/history/HistoricDateElement.java @@ -22,6 +22,7 @@ package net.time4j.history; import net.time4j.PlainDate; +import net.time4j.base.GregorianMath; import net.time4j.engine.BasicElement; import net.time4j.engine.ChronoElement; import net.time4j.engine.ChronoEntity; @@ -43,7 +44,6 @@ final class HistoricDateElement //~ Statische Felder/Initialisierungen -------------------------------- - private static final int YMAX = 999999999; private static final long serialVersionUID = -5386613740709845550L; //~ Instanzvariablen -------------------------------------------------- @@ -167,7 +167,7 @@ public HistoricDate getMinimum(C context) { } else if (this.history == ChronoHistory.PROLEPTIC_JULIAN) { return HistoricDate.of(HistoricEra.BC, ChronoHistory.JULIAN_YMAX + 1, 1, 1); } else if (this.history == ChronoHistory.PROLEPTIC_GREGORIAN) { - return HistoricDate.of(HistoricEra.BC, YMAX, 1, 1); + return HistoricDate.of(HistoricEra.BC, GregorianMath.MAX_YEAR + 1, 1, 1); } else { return HistoricDate.of(HistoricEra.BC, 45, 1, 1); } @@ -182,7 +182,7 @@ public HistoricDate getMaximum(C context) { } else if (this.history == ChronoHistory.PROLEPTIC_JULIAN) { return HistoricDate.of(HistoricEra.AD, ChronoHistory.JULIAN_YMAX, 12, 31); } else if (this.history == ChronoHistory.PROLEPTIC_GREGORIAN) { - return HistoricDate.of(HistoricEra.AD, YMAX, 12, 31); + return HistoricDate.of(HistoricEra.AD, GregorianMath.MAX_YEAR, 12, 31); } else { return HistoricDate.of(HistoricEra.AD, 9999, 12, 31); } diff --git a/time4j-android/src/main/java/net/time4j/history/HistoricIntegerElement.java b/time4j-android/src/main/java/net/time4j/history/HistoricIntegerElement.java index c09a726..1e18ed9 100644 --- a/time4j-android/src/main/java/net/time4j/history/HistoricIntegerElement.java +++ b/time4j-android/src/main/java/net/time4j/history/HistoricIntegerElement.java @@ -24,6 +24,7 @@ import net.time4j.Month; import net.time4j.PlainDate; import net.time4j.base.GregorianDate; +import net.time4j.base.GregorianMath; import net.time4j.base.MathUtils; import net.time4j.engine.AttributeQuery; import net.time4j.engine.BasicElement; @@ -691,9 +692,12 @@ public Integer getMaximum(C context) { max++; } } else if (this.history == ChronoHistory.PROLEPTIC_GREGORIAN) { - max = 999999999; + max = GregorianMath.MAX_YEAR; + if (current.getEra() == HistoricEra.BC) { + max++; + } } else { - max = 9999; + max = ((current.getEra() == HistoricEra.BC) ? 45 : 9999); } if (this.index == CENTURY_INDEX) { max = ((max - 1) / 100) + 1;