Package org.joda.time

Class MutableDateTime.Property

  • All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    MutableDateTime

    public static final class MutableDateTime.Property
    extends AbstractReadableInstantFieldProperty
    MutableDateTime.Property binds a MutableDateTime to a DateTimeField allowing powerful datetime functionality to be easily accessed.

    The example below shows how to use the property to change the value of a MutableDateTime object.

     MutableDateTime dt = new MutableDateTime(1972, 12, 3, 13, 32, 19, 123);
     dt.year().add(20);
     dt.second().roundFloor().minute().set(10);
     

    MutableDateTime.Propery itself is thread-safe and immutable, but the MutableDateTime being operated on is not.

    Since:
    1.0
    See Also:
    Serialized Form
    • Method Detail

      • getMutableDateTime

        public MutableDateTime getMutableDateTime()
        Gets the mutable datetime being used.
        Returns:
        the mutable datetime
      • add

        public MutableDateTime add​(int value)
        Adds a value to the millis value.
        Parameters:
        value - the value to add
        Returns:
        the mutable datetime being used, so calls can be chained
        See Also:
        DateTimeField.add(long,int)
      • add

        public MutableDateTime add​(long value)
        Adds a value to the millis value.
        Parameters:
        value - the value to add
        Returns:
        the mutable datetime being used, so calls can be chained
        See Also:
        DateTimeField.add(long,long)
      • addWrapField

        public MutableDateTime addWrapField​(int value)
        Adds a value, possibly wrapped, to the millis value.
        Parameters:
        value - the value to add
        Returns:
        the mutable datetime being used, so calls can be chained
        See Also:
        DateTimeField.addWrapField(long, int)
      • set

        public MutableDateTime set​(java.lang.String text,
                                   java.util.Locale locale)
        Sets a text value.
        Parameters:
        text - the text value to set
        locale - optional locale to use for selecting a text symbol
        Returns:
        the mutable datetime being used, so calls can be chained
        Throws:
        java.lang.IllegalArgumentException - if the text value isn't valid
        See Also:
        DateTimeField.set(long,java.lang.String,java.util.Locale)
      • set

        public MutableDateTime set​(java.lang.String text)
        Sets a text value.
        Parameters:
        text - the text value to set
        Returns:
        the mutable datetime being used, so calls can be chained
        Throws:
        java.lang.IllegalArgumentException - if the text value isn't valid
        See Also:
        DateTimeField.set(long,java.lang.String)
      • roundHalfFloor

        public MutableDateTime roundHalfFloor()
        Round to the nearest whole unit of this field, favoring the floor if halfway.
        Returns:
        the mutable datetime being used, so calls can be chained
        See Also:
        DateTimeField.roundHalfFloor(long)
      • roundHalfCeiling

        public MutableDateTime roundHalfCeiling()
        Round to the nearest whole unit of this field, favoring the ceiling if halfway.
        Returns:
        the mutable datetime being used, so calls can be chained
        See Also:
        DateTimeField.roundHalfCeiling(long)
      • roundHalfEven

        public MutableDateTime roundHalfEven()
        Round to the nearest whole unit of this field. If halfway, the ceiling is favored over the floor only if it makes this field's value even.
        Returns:
        the mutable datetime being used, so calls can be chained
        See Also:
        DateTimeField.roundHalfEven(long)