src/share/classes/java/time/temporal/IsoFields.java

Print this page




 336             @SuppressWarnings("unchecked")
 337             @Override
 338             public <R extends Temporal> R adjustInto(R temporal, long newValue) {
 339                 // calls getFrom() to check if supported
 340                 long curValue = getFrom(temporal);
 341                 range().checkValidValue(newValue, this);  // strictly check from 1 to 4
 342                 return (R) temporal.with(MONTH_OF_YEAR, temporal.getLong(MONTH_OF_YEAR) + (newValue - curValue) * 3);
 343             }
 344         },
 345         WEEK_OF_WEEK_BASED_YEAR {
 346             @Override
 347             public String getName() {
 348                 return "WeekOfWeekBasedYear";
 349             }
 350 
 351             @Override
 352             public String getDisplayName(Locale locale) {
 353                 Objects.requireNonNull(locale, "locale");
 354                 LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
 355                                             .getLocaleResources(locale);
 356                 ResourceBundle rb = lr.getFormatData();
 357                 return rb.containsKey("field.week") ? rb.getString("field.week") : getName();
 358             }
 359 
 360             @Override
 361             public TemporalUnit getBaseUnit() {
 362                 return WEEKS;
 363             }
 364             @Override
 365             public TemporalUnit getRangeUnit() {
 366                 return WEEK_BASED_YEARS;
 367             }
 368             @Override
 369             public ValueRange range() {
 370                 return ValueRange.of(1, 52, 53);
 371             }
 372             @Override
 373             public boolean isSupportedBy(TemporalAccessor temporal) {
 374                 return temporal.isSupported(EPOCH_DAY) && isIso(temporal);
 375             }
 376             @Override




 336             @SuppressWarnings("unchecked")
 337             @Override
 338             public <R extends Temporal> R adjustInto(R temporal, long newValue) {
 339                 // calls getFrom() to check if supported
 340                 long curValue = getFrom(temporal);
 341                 range().checkValidValue(newValue, this);  // strictly check from 1 to 4
 342                 return (R) temporal.with(MONTH_OF_YEAR, temporal.getLong(MONTH_OF_YEAR) + (newValue - curValue) * 3);
 343             }
 344         },
 345         WEEK_OF_WEEK_BASED_YEAR {
 346             @Override
 347             public String getName() {
 348                 return "WeekOfWeekBasedYear";
 349             }
 350 
 351             @Override
 352             public String getDisplayName(Locale locale) {
 353                 Objects.requireNonNull(locale, "locale");
 354                 LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
 355                                             .getLocaleResources(locale);
 356                 ResourceBundle rb = lr.getJavaTimeFormatData();
 357                 return rb.containsKey("field.week") ? rb.getString("field.week") : getName();
 358             }
 359 
 360             @Override
 361             public TemporalUnit getBaseUnit() {
 362                 return WEEKS;
 363             }
 364             @Override
 365             public TemporalUnit getRangeUnit() {
 366                 return WEEK_BASED_YEARS;
 367             }
 368             @Override
 369             public ValueRange range() {
 370                 return ValueRange.of(1, 52, 53);
 371             }
 372             @Override
 373             public boolean isSupportedBy(TemporalAccessor temporal) {
 374                 return temporal.isSupported(EPOCH_DAY) && isIso(temporal);
 375             }
 376             @Override