Class Attributes.Builder

java.lang.Object
net.time4j.format.Attributes.Builder
Enclosing class:
Attributes

public static final class Attributes.Builder extends Object

Builds a collection of format attributes.

  • Constructor Details

    • Builder

      public Builder()

      Default constructor.

    • Builder

      public Builder(Chronology<?> chronology)

      Constructor for determining the calendar type.

      Parameters:
      chronology - object with possible calendar type
      Since:
      3.0
      See Also:
      Attributes.CALENDAR_TYPE
  • Method Details

    • setLanguage

      public Attributes.Builder setLanguage(Locale locale)

      Sets the language.

      Parameters:
      locale - new language setting
      Returns:
      this instance for method chaining
      See Also:
      Attributes.LANGUAGE
    • setTimezone

      public Attributes.Builder setTimezone(TZID tzid)

      Sets the timezone reference.

      Parameters:
      tzid - timezone id
      Returns:
      this instance for method chaining
      See Also:
      Attributes.TIMEZONE_ID
    • setTimezone

      public Attributes.Builder setTimezone(String tzid)

      Sets the timezone reference.

      Parameters:
      tzid - timezone id
      Returns:
      this instance for method chaining
      Throws:
      IllegalArgumentException - if given timezone cannot be loaded
      Since:
      1.1
      See Also:
      Attributes.TIMEZONE_ID
    • setStdTimezone

      public Attributes.Builder setStdTimezone()

      Sets the system timezone reference.

      Returns:
      this instance for method chaining
      See Also:
      Attributes.TIMEZONE_ID, Timezone.ofSystem()
    • setCalendarVariant

      public Attributes.Builder setCalendarVariant(String variant)

      Sets the calendar variant.

      Parameters:
      variant - calendar variant
      Returns:
      this instance for method chaining
      Since:
      3.5/4.3
      See Also:
      Attributes.CALENDAR_VARIANT, CalendarVariant
    • set

      public Attributes.Builder set(AttributeKey<Boolean> key, boolean value)

      Sets an attribute of boolean-type.

      Parameters:
      key - attribute key
      value - attribute value
      Returns:
      this instance for method chaining
    • set

      public Attributes.Builder set(AttributeKey<Integer> key, int value)

      Sets an attribute of int-type.

      Parameters:
      key - attribute key
      value - attribute value
      Returns:
      this instance for method chaining
      Throws:
      IllegalArgumentException - if an invalid pivot year smaller than 100 is given
    • set

      public Attributes.Builder set(AttributeKey<Character> key, char value)

      Sets an attribute of char-type.

      Parameters:
      key - attribute key
      value - attribute value
      Returns:
      this instance for method chaining
    • set

      public <A extends Enum<A>> Attributes.Builder set(AttributeKey<A> key, A value)

      Sets an attribute of enum-type.

      Type Parameters:
      A - generic type of attribute
      Parameters:
      key - attribute key
      value - attribute value
      Returns:
      this instance for method chaining
    • setAll

      public Attributes.Builder setAll(Attributes attributes)

      Accepts all given attributes.

      If an attribute already exists then it will be overridden.

      Parameters:
      attributes - format attributes
      Returns:
      this instance for method chaining
    • remove

      public Attributes.Builder remove(AttributeKey<?> key)

      Removes the specified attribute.

      Parameters:
      key - attribute key to be removed
      Returns:
      this instance for method chaining
    • build

      public Attributes build()

      Creates a new unmodifiable collection of format attributes.

      Returns:
      new instance of Attributes