@Override protected ChronoLocalDate chronoLocalDateOf(final MinguoEra era, final int prolepticYear, final int month, final int dayOfMonth) { return MinguoDate.of(prolepticYear, month, dayOfMonth); }
@Override public MinguoDate with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; if (getLong(f) == newValue) { 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: { 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)); case YEAR: return with(isoDate.withYear(nvalue + YEARS_DIFFERENCE)); case ERA: return with(isoDate.withYear((1 - getProlepticYear()) + YEARS_DIFFERENCE)); } } } return with(isoDate.with(field, newValue)); } return field.adjustInto(this, newValue); }
long months = Jdk8Methods.safeSubtract(fieldValues.remove(MONTH_OF_YEAR), 1); long days = Jdk8Methods.safeSubtract(fieldValues.remove(DAY_OF_MONTH), 1); return date(y, 1, 1).plusMonths(months).plusDays(days); } else { 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 && dom > 28) { dom = Math.min(dom, date(y, moy, 1).lengthOfMonth()); long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1); long days = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH), 1); return date(y, 1, 1).plus(months, MONTHS).plus(weeks, WEEKS).plus(days, DAYS); MinguoDate date = date(y, moy, 1).plus((aw - 1) * 7 + (ad - 1), DAYS); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1); long days = Jdk8Methods.safeSubtract(fieldValues.remove(DAY_OF_WEEK), 1); return date(y, 1, 1).plus(months, MONTHS).plus(weeks, WEEKS).plus(days, DAYS); MinguoDate date = date(y, moy, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); if (resolverStyle == ResolverStyle.LENIENT) { long days = Jdk8Methods.safeSubtract(fieldValues.remove(DAY_OF_YEAR), 1); return dateYearDay(y, 1).plusDays(days);
@Override protected MinguoDate getReferenceValue(Clock reference) { return MinguoDate.now( reference ); }
@Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { if (isSupported(field)) { ChronoField f = (ChronoField) field; switch (f) { case DAY_OF_MONTH: case DAY_OF_YEAR: case ALIGNED_WEEK_OF_MONTH: return isoDate.range(field); case YEAR_OF_ERA: { ValueRange range = YEAR.range(); long max = (getProlepticYear() <= 0 ? -range.getMinimum() + 1 + YEARS_DIFFERENCE : range.getMaximum() - YEARS_DIFFERENCE); return ValueRange.of(1, max); } } return getChronology().range(f); } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.rangeRefinedBy(this); }
public static MinguoDate from(TemporalAccessor temporal) { return MinguoDate.from(temporal); }
@Override // override with covariant return type public MinguoDate date(int prolepticYear, int month, int dayOfMonth) { return new MinguoDate(LocalDate.of(prolepticYear + YEARS_DIFFERENCE, month, dayOfMonth)); }
@Override // override for performance public int hashCode() { return getChronology().getId().hashCode() ^ isoDate.hashCode(); }
@Override protected MinguoDate getReferenceValue(Clock reference) { return MinguoDate.now( reference ); }
public PastDummyEntity(ZonedDateTime dateTime) { calendar = GregorianCalendar.from( dateTime ); date = calendar.getTime(); instant = dateTime.toInstant(); localDateTime = dateTime.toLocalDateTime(); hijrahDate = HijrahDate.from( dateTime ); japaneseDate = JapaneseDate.from( dateTime ); localDate = LocalDate.from( dateTime ); minguoDate = MinguoDate.from( dateTime ); offsetDateTime = dateTime.toOffsetDateTime(); thaiBuddhistDate = ThaiBuddhistDate.from( dateTime ); year = Year.from( dateTime ); yearMonth = YearMonth.from( dateTime ); zonedDateTime = dateTime; } }
/** * Obtains the current {@code MinguoDate} from the specified clock. * <p> * This will query the specified clock to obtain the current date - today. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@linkplain Clock dependency injection}. * * @param clock the clock to use, not null * @return the current date, not null * @throws DateTimeException if the current date cannot be obtained */ public static MinguoDate now(Clock clock) { return new MinguoDate(LocalDate.now(clock)); }
@Override public ChronoPeriod until(ChronoLocalDate endDate) { Period period = isoDate.until(endDate); return getChronology().period(period.getYears(), period.getMonths(), period.getDays()); }
@Override protected ChronoLocalDate chronoLocalDateOf(final MinguoEra era, final int prolepticYear, final int month, final int dayOfMonth) { return MinguoDate.of(prolepticYear, month, dayOfMonth); }
@Override protected MinguoDate getReferenceValue(Clock reference) { return MinguoDate.now( reference ); }
public FutureOrPresentDummyEntity(ZonedDateTime dateTime) { calendar = GregorianCalendar.from( dateTime ); date = calendar.getTime(); instant = dateTime.toInstant(); localDateTime = dateTime.toLocalDateTime(); hijrahDate = HijrahDate.from( dateTime ); japaneseDate = JapaneseDate.from( dateTime ); localDate = LocalDate.from( dateTime ); minguoDate = MinguoDate.from( dateTime ); offsetDateTime = dateTime.toOffsetDateTime(); thaiBuddhistDate = ThaiBuddhistDate.from( dateTime ); year = Year.from( dateTime ); yearMonth = YearMonth.from( dateTime ); zonedDateTime = dateTime; } }
@Override // override with covariant return type public MinguoDate date(TemporalAccessor temporal) { if (temporal instanceof MinguoDate) { return (MinguoDate) temporal; } return new MinguoDate(LocalDate.from(temporal)); }
@Override protected ChronoLocalDate chronoLocalDateOf(final MinguoEra era, final int prolepticYear, final int month, final int dayOfMonth) { return MinguoDate.of(prolepticYear, month, dayOfMonth); }
@Override protected MinguoDate getReferenceValue(Clock reference) { return MinguoDate.now( reference ); }
public PastOrPresentDummyEntity(ZonedDateTime dateTime) { calendar = GregorianCalendar.from( dateTime ); date = calendar.getTime(); instant = dateTime.toInstant(); localDateTime = dateTime.toLocalDateTime(); hijrahDate = HijrahDate.from( dateTime ); japaneseDate = JapaneseDate.from( dateTime ); localDate = LocalDate.from( dateTime ); minguoDate = MinguoDate.from( dateTime ); offsetDateTime = dateTime.toOffsetDateTime(); thaiBuddhistDate = ThaiBuddhistDate.from( dateTime ); year = Year.from( dateTime ); yearMonth = YearMonth.from( dateTime ); zonedDateTime = dateTime; } }