src/share/classes/java/time/DayOfWeek.java

Print this page

        

*** 168,179 **** //----------------------------------------------------------------------- /** * Obtains an instance of {@code DayOfWeek} from a temporal object. * <p> ! * A {@code TemporalAccessor} represents some form of date and time information. ! * This factory converts the arbitrary temporal object to an instance of {@code DayOfWeek}. * <p> * The conversion extracts the {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} field. * <p> * This method matches the signature of the functional interface {@link TemporalQuery} * allowing it to be used as a query via method reference, {@code DayOfWeek::from}. --- 168,180 ---- //----------------------------------------------------------------------- /** * Obtains an instance of {@code DayOfWeek} from a temporal object. * <p> ! * This obtains a day-of-week based on the specified temporal. ! * A {@code TemporalAccessor} represents an arbitrary set of date and time information, ! * which this factory converts to an instance of {@code DayOfWeek}. * <p> * The conversion extracts the {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} field. * <p> * This method matches the signature of the functional interface {@link TemporalQuery} * allowing it to be used as a query via method reference, {@code DayOfWeek::from}.
*** 204,224 **** //----------------------------------------------------------------------- /** * Gets the textual representation, such as 'Mon' or 'Friday'. * <p> ! * This returns the textual name used to identify the day-of-week. ! * The parameters control the length of the returned text and the locale. * <p> * If no textual mapping is found then the {@link #getValue() numeric value} is returned. * * @param style the length of the text required, not null * @param locale the locale to use, not null * @return the text value of the day-of-week, not null */ ! public String getText(TextStyle style, Locale locale) { ! return new DateTimeFormatterBuilder().appendText(DAY_OF_WEEK, style).toFormatter(locale).print(this); } //----------------------------------------------------------------------- /** * Checks if the specified field is supported. --- 205,226 ---- //----------------------------------------------------------------------- /** * Gets the textual representation, such as 'Mon' or 'Friday'. * <p> ! * This returns the textual name used to identify the day-of-week, ! * suitable for presentation to the user. ! * The parameters control the style of the returned text and the locale. * <p> * If no textual mapping is found then the {@link #getValue() numeric value} is returned. * * @param style the length of the text required, not null * @param locale the locale to use, not null * @return the text value of the day-of-week, not null */ ! public String getDisplayName(TextStyle style, Locale locale) { ! return new DateTimeFormatterBuilder().appendText(DAY_OF_WEEK, style).toFormatter(locale).format(this); } //----------------------------------------------------------------------- /** * Checks if the specified field is supported.
*** 230,240 **** * If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then * this method returns true. * All other {@code ChronoField} instances will return false. * <p> * If the field is not a {@code ChronoField}, then the result of this method ! * is obtained by invoking {@code TemporalField.doIsSupported(TemporalAccessor)} * passing {@code this} as the argument. * Whether the field is supported is determined by the field. * * @param field the field to check, null returns false * @return true if the field is supported on this day-of-week, false if not --- 232,242 ---- * If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then * this method returns true. * All other {@code ChronoField} instances will return false. * <p> * If the field is not a {@code ChronoField}, then the result of this method ! * is obtained by invoking {@code TemporalField.isSupportedBy(TemporalAccessor)} * passing {@code this} as the argument. * Whether the field is supported is determined by the field. * * @param field the field to check, null returns false * @return true if the field is supported on this day-of-week, false if not
*** 242,252 **** @Override public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { return field == DAY_OF_WEEK; } ! return field != null && field.doIsSupported(this); } /** * Gets the range of valid values for the specified field. * <p> --- 244,254 ---- @Override public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { return field == DAY_OF_WEEK; } ! return field != null && field.isSupportedBy(this); } /** * Gets the range of valid values for the specified field. * <p>
*** 258,268 **** * If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * range of the day-of-week, from 1 to 7, will be returned. * All other {@code ChronoField} instances will throw a {@code DateTimeException}. * <p> * If the field is not a {@code ChronoField}, then the result of this method ! * is obtained by invoking {@code TemporalField.doRange(TemporalAccessor)} * passing {@code this} as the argument. * Whether the range can be obtained is determined by the field. * * @param field the field to query the range for, not null * @return the range of valid values for the field, not null --- 260,270 ---- * If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * range of the day-of-week, from 1 to 7, will be returned. * All other {@code ChronoField} instances will throw a {@code DateTimeException}. * <p> * If the field is not a {@code ChronoField}, then the result of this method ! * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} * passing {@code this} as the argument. * Whether the range can be obtained is determined by the field. * * @param field the field to query the range for, not null * @return the range of valid values for the field, not null
*** 287,305 **** * If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * value of the day-of-week, from 1 to 7, will be returned. * All other {@code ChronoField} instances will throw a {@code DateTimeException}. * <p> * If the field is not a {@code ChronoField}, then the result of this method ! * is obtained by invoking {@code TemporalField.doGet(TemporalAccessor)} * passing {@code this} as the argument. Whether the value can be obtained, * and what the value represents, is determined by the field. * * @param field the field to get, not null * @return the value for the field, within the valid range of values * @throws DateTimeException if a value for the field cannot be obtained - * @throws DateTimeException if the range of valid values for the field exceeds an {@code int} - * @throws DateTimeException if the value is outside the range of valid values for the field * @throws ArithmeticException if numeric overflow occurs */ @Override public int get(TemporalField field) { if (field == DAY_OF_WEEK) { --- 289,305 ---- * If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * value of the day-of-week, from 1 to 7, will be returned. * All other {@code ChronoField} instances will throw a {@code DateTimeException}. * <p> * If the field is not a {@code ChronoField}, then the result of this method ! * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} * passing {@code this} as the argument. Whether the value can be obtained, * and what the value represents, is determined by the field. * * @param field the field to get, not null * @return the value for the field, within the valid range of values * @throws DateTimeException if a value for the field cannot be obtained * @throws ArithmeticException if numeric overflow occurs */ @Override public int get(TemporalField field) { if (field == DAY_OF_WEEK) {
*** 318,328 **** * If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * value of the day-of-week, from 1 to 7, will be returned. * All other {@code ChronoField} instances will throw a {@code DateTimeException}. * <p> * If the field is not a {@code ChronoField}, then the result of this method ! * is obtained by invoking {@code TemporalField.doGet(TemporalAccessor)} * passing {@code this} as the argument. Whether the value can be obtained, * and what the value represents, is determined by the field. * * @param field the field to get, not null * @return the value for the field --- 318,328 ---- * If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * value of the day-of-week, from 1 to 7, will be returned. * All other {@code ChronoField} instances will throw a {@code DateTimeException}. * <p> * If the field is not a {@code ChronoField}, then the result of this method ! * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} * passing {@code this} as the argument. Whether the value can be obtained, * and what the value represents, is determined by the field. * * @param field the field to get, not null * @return the value for the field
*** 334,344 **** if (field == DAY_OF_WEEK) { return getValue(); } else if (field instanceof ChronoField) { throw new DateTimeException("Unsupported field: " + field.getName()); } ! return field.doGet(this); } //----------------------------------------------------------------------- /** * Returns the day-of-week that is the specified number of days after this one. --- 334,344 ---- if (field == DAY_OF_WEEK) { return getValue(); } else if (field instanceof ChronoField) { throw new DateTimeException("Unsupported field: " + field.getName()); } ! return field.getFrom(this); } //----------------------------------------------------------------------- /** * Returns the day-of-week that is the specified number of days after this one.