src/share/classes/java/time/format/DateTimeFormatterBuilder.java

Print this page




 922      * This appends a localized zone offset to the builder, the format of the
 923      * localized offset is controlled by the specified {@link FormatStyle style}
 924      * to this method:
 925      * <ul>
 926      * <li>{@link TextStyle#FULL full} - formats with localized offset text, such
 927      * as 'GMT, 2-digit hour and minute field, optional second field if non-zero,
 928      * and colon.
 929      * <li>{@link TextStyle#SHORT short} - formats with localized offset text,
 930      * such as 'GMT, hour without leading zero, optional 2-digit minute and
 931      * second if non-zero, and colon.
 932      * </ul>
 933      * <p>
 934      * During formatting, the offset is obtained using a mechanism equivalent
 935      * to querying the temporal with {@link TemporalQueries#offset()}.
 936      * If the offset cannot be obtained then an exception is thrown unless the
 937      * section of the formatter is optional.
 938      * <p>
 939      * During parsing, the offset is parsed using the format defined above.
 940      * If the offset cannot be parsed then an exception is thrown unless the
 941      * section of the formatter is optional.
 942      * <p>
 943      * @param style  the format style to use, not null
 944      * @return this, for chaining, not null
 945      * @throws IllegalArgumentException if style is neither {@link TextStyle#FULL
 946      * full} nor {@link TextStyle#SHORT short}
 947      */
 948     public DateTimeFormatterBuilder appendLocalizedOffset(TextStyle style) {
 949         Objects.requireNonNull(style, "style");
 950         if (style != TextStyle.FULL && style != TextStyle.SHORT) {
 951             throw new IllegalArgumentException("Style must be either full or short");
 952         }
 953         appendInternal(new LocalizedOffsetIdPrinterParser(style));
 954         return this;
 955     }
 956 
 957     //-----------------------------------------------------------------------
 958     /**
 959      * Appends the time-zone ID, such as 'Europe/Paris' or '+02:00', to the formatter.
 960      * <p>
 961      * This appends an instruction to format/parse the zone ID to the builder.
 962      * The zone ID is obtained in a strict manner suitable for {@code ZonedDateTime}.




 922      * This appends a localized zone offset to the builder, the format of the
 923      * localized offset is controlled by the specified {@link FormatStyle style}
 924      * to this method:
 925      * <ul>
 926      * <li>{@link TextStyle#FULL full} - formats with localized offset text, such
 927      * as 'GMT, 2-digit hour and minute field, optional second field if non-zero,
 928      * and colon.
 929      * <li>{@link TextStyle#SHORT short} - formats with localized offset text,
 930      * such as 'GMT, hour without leading zero, optional 2-digit minute and
 931      * second if non-zero, and colon.
 932      * </ul>
 933      * <p>
 934      * During formatting, the offset is obtained using a mechanism equivalent
 935      * to querying the temporal with {@link TemporalQueries#offset()}.
 936      * If the offset cannot be obtained then an exception is thrown unless the
 937      * section of the formatter is optional.
 938      * <p>
 939      * During parsing, the offset is parsed using the format defined above.
 940      * If the offset cannot be parsed then an exception is thrown unless the
 941      * section of the formatter is optional.
 942      *
 943      * @param style  the format style to use, not null
 944      * @return this, for chaining, not null
 945      * @throws IllegalArgumentException if style is neither {@link TextStyle#FULL
 946      * full} nor {@link TextStyle#SHORT short}
 947      */
 948     public DateTimeFormatterBuilder appendLocalizedOffset(TextStyle style) {
 949         Objects.requireNonNull(style, "style");
 950         if (style != TextStyle.FULL && style != TextStyle.SHORT) {
 951             throw new IllegalArgumentException("Style must be either full or short");
 952         }
 953         appendInternal(new LocalizedOffsetIdPrinterParser(style));
 954         return this;
 955     }
 956 
 957     //-----------------------------------------------------------------------
 958     /**
 959      * Appends the time-zone ID, such as 'Europe/Paris' or '+02:00', to the formatter.
 960      * <p>
 961      * This appends an instruction to format/parse the zone ID to the builder.
 962      * The zone ID is obtained in a strict manner suitable for {@code ZonedDateTime}.