mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
parent
749c4a054b
commit
170d8a7fae
12 changed files with 62 additions and 61 deletions
|
@ -110,7 +110,7 @@ import java.util.Objects;
|
|||
* int year = date.get(ChronoField.YEAR);
|
||||
* System.out.printf(" Today is %s %s %d-%s-%d%n", date.getChronology().getID(),
|
||||
* dow, day, month, year);
|
||||
|
||||
*
|
||||
* // Print today's date and the last day of the year
|
||||
* ChronoLocalDate now1 = Chronology.of("Hijrah").dateNow();
|
||||
* ChronoLocalDate first = now1.with(ChronoField.DAY_OF_MONTH, 1)
|
||||
|
|
|
@ -201,7 +201,7 @@ public interface ChronoLocalDateTime<D extends ChronoLocalDate>
|
|||
*
|
||||
* @return the date part of this date-time, not null
|
||||
*/
|
||||
D toLocalDate() ;
|
||||
D toLocalDate();
|
||||
|
||||
/**
|
||||
* Gets the local time part of this date-time.
|
||||
|
|
|
@ -736,8 +736,8 @@ public interface Chronology extends Comparable<Chronology> {
|
|||
* @throws DateTimeException if any of the values are out of range
|
||||
* @since 9
|
||||
*/
|
||||
public default long epochSecond(int prolepticYear, int month, int dayOfMonth,
|
||||
int hour, int minute, int second, ZoneOffset zoneOffset) {
|
||||
public default long epochSecond(int prolepticYear, int month, int dayOfMonth,
|
||||
int hour, int minute, int second, ZoneOffset zoneOffset) {
|
||||
Objects.requireNonNull(zoneOffset, "zoneOffset");
|
||||
HOUR_OF_DAY.checkValidValue(hour);
|
||||
MINUTE_OF_HOUR.checkValidValue(minute);
|
||||
|
@ -765,8 +765,8 @@ public interface Chronology extends Comparable<Chronology> {
|
|||
* @throws DateTimeException if any of the values are out of range
|
||||
* @since 9
|
||||
*/
|
||||
public default long epochSecond(Era era, int yearOfEra, int month, int dayOfMonth,
|
||||
int hour, int minute, int second, ZoneOffset zoneOffset) {
|
||||
public default long epochSecond(Era era, int yearOfEra, int month, int dayOfMonth,
|
||||
int hour, int minute, int second, ZoneOffset zoneOffset) {
|
||||
Objects.requireNonNull(era, "era");
|
||||
return epochSecond(prolepticYear(era, yearOfEra), month, dayOfMonth, hour, minute, second, zoneOffset);
|
||||
}
|
||||
|
|
|
@ -287,9 +287,9 @@ public final class IsoChronology extends AbstractChronology implements Serializa
|
|||
* or if the day-of-month is invalid for the month-of-year
|
||||
* @since 9
|
||||
*/
|
||||
@Override
|
||||
public long epochSecond(int prolepticYear, int month, int dayOfMonth,
|
||||
int hour, int minute, int second, ZoneOffset zoneOffset) {
|
||||
@Override
|
||||
public long epochSecond(int prolepticYear, int month, int dayOfMonth,
|
||||
int hour, int minute, int second, ZoneOffset zoneOffset) {
|
||||
YEAR.checkValidValue(prolepticYear);
|
||||
MONTH_OF_YEAR.checkValidValue(month);
|
||||
DAY_OF_MONTH.checkValidValue(dayOfMonth);
|
||||
|
|
|
@ -459,38 +459,38 @@ public final class JapaneseChronology extends AbstractChronology implements Seri
|
|||
return era.getPrivateEra().getSinceDate().getYear() + yearOfEra - 1;
|
||||
}
|
||||
|
||||
private ChronoLocalDate resolveYMD(JapaneseEra era, int yoe, Map<TemporalField,Long> fieldValues, ResolverStyle resolverStyle) {
|
||||
fieldValues.remove(ERA);
|
||||
fieldValues.remove(YEAR_OF_ERA);
|
||||
if (resolverStyle == ResolverStyle.LENIENT) {
|
||||
int y = prolepticYearLenient(era, yoe);
|
||||
long months = Math.subtractExact(fieldValues.remove(MONTH_OF_YEAR), 1);
|
||||
long days = Math.subtractExact(fieldValues.remove(DAY_OF_MONTH), 1);
|
||||
return date(y, 1, 1).plus(months, MONTHS).plus(days, DAYS);
|
||||
}
|
||||
int moy = range(MONTH_OF_YEAR).checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR), MONTH_OF_YEAR);
|
||||
int dom = range(DAY_OF_MONTH).checkValidIntValue(fieldValues.remove(DAY_OF_MONTH), DAY_OF_MONTH);
|
||||
if (resolverStyle == ResolverStyle.SMART) { // previous valid
|
||||
if (yoe < 1) {
|
||||
throw new DateTimeException("Invalid YearOfEra: " + yoe);
|
||||
}
|
||||
int y = prolepticYearLenient(era, yoe);
|
||||
JapaneseDate result;
|
||||
try {
|
||||
result = date(y, moy, dom);
|
||||
} catch (DateTimeException ex) {
|
||||
result = date(y, moy, 1).with(TemporalAdjusters.lastDayOfMonth());
|
||||
}
|
||||
// handle the era being changed
|
||||
// only allow if the new date is in the same Jan-Dec as the era change
|
||||
// determine by ensuring either original yoe or result yoe is 1
|
||||
if (result.getEra() != era && result.get(YEAR_OF_ERA) > 1 && yoe > 1) {
|
||||
throw new DateTimeException("Invalid YearOfEra for Era: " + era + " " + yoe);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return date(era, yoe, moy, dom);
|
||||
}
|
||||
private ChronoLocalDate resolveYMD(JapaneseEra era, int yoe, Map<TemporalField,Long> fieldValues, ResolverStyle resolverStyle) {
|
||||
fieldValues.remove(ERA);
|
||||
fieldValues.remove(YEAR_OF_ERA);
|
||||
if (resolverStyle == ResolverStyle.LENIENT) {
|
||||
int y = prolepticYearLenient(era, yoe);
|
||||
long months = Math.subtractExact(fieldValues.remove(MONTH_OF_YEAR), 1);
|
||||
long days = Math.subtractExact(fieldValues.remove(DAY_OF_MONTH), 1);
|
||||
return date(y, 1, 1).plus(months, MONTHS).plus(days, DAYS);
|
||||
}
|
||||
int moy = range(MONTH_OF_YEAR).checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR), MONTH_OF_YEAR);
|
||||
int dom = range(DAY_OF_MONTH).checkValidIntValue(fieldValues.remove(DAY_OF_MONTH), DAY_OF_MONTH);
|
||||
if (resolverStyle == ResolverStyle.SMART) { // previous valid
|
||||
if (yoe < 1) {
|
||||
throw new DateTimeException("Invalid YearOfEra: " + yoe);
|
||||
}
|
||||
int y = prolepticYearLenient(era, yoe);
|
||||
JapaneseDate result;
|
||||
try {
|
||||
result = date(y, moy, dom);
|
||||
} catch (DateTimeException ex) {
|
||||
result = date(y, moy, 1).with(TemporalAdjusters.lastDayOfMonth());
|
||||
}
|
||||
// handle the era being changed
|
||||
// only allow if the new date is in the same Jan-Dec as the era change
|
||||
// determine by ensuring either original yoe or result yoe is 1
|
||||
if (result.getEra() != era && result.get(YEAR_OF_ERA) > 1 && yoe > 1) {
|
||||
throw new DateTimeException("Invalid YearOfEra for Era: " + era + " " + yoe);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return date(era, yoe, moy, dom);
|
||||
}
|
||||
|
||||
private ChronoLocalDate resolveYD(JapaneseEra era, int yoe, Map <TemporalField,Long> fieldValues, ResolverStyle resolverStyle) {
|
||||
fieldValues.remove(ERA);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue