Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  Copyright 2001-2005 Stephen Colebourne
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  *  Unless required by applicable law or agreed to in writing, software
  *  distributed under the License is distributed on an "AS IS" BASIS,
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
 package org.goda.time;

Defines a duration of time that can be queried and modified using datetime fields.

The implementation of this interface will be mutable. It may provide more advanced methods than those in the interface.

Author(s):
Brian S O'Neill
Stephen Colebourne
Since:
1.0
 
 public interface ReadWritablePeriod extends ReadablePeriod {

    
Clears the period, setting all values back to zero.
 
     void clear();

    
Sets the value of one of the fields by index.

Parameters:
index the field index
value the new value for the field
Throws:
java.lang.IndexOutOfBoundsException if the index is invalid
 
     void setValue(int indexint value);

    
Sets the value of one of the fields.

The field type specified must be one of those that is supported by the period.

Parameters:
field a DurationFieldType instance that is supported by this period
value the new value for the field
Throws:
java.lang.IllegalArgumentException if the field is null or not supported
 
     void set(DurationFieldType fieldint value);

    
Sets all the fields in one go from another ReadablePeriod.

Parameters:
period the period to set, null means zero length period
Throws:
java.lang.IllegalArgumentException if an unsupported field's value is non-zero
 
     void setPeriod(ReadablePeriod period);

    
Sets all the fields in one go.

Parameters:
years amount of years in this period, which must be zero if unsupported
months amount of months in this period, which must be zero if unsupported
weeks amount of weeks in this period, which must be zero if unsupported
days amount of days in this period, which must be zero if unsupported
hours amount of hours in this period, which must be zero if unsupported
minutes amount of minutes in this period, which must be zero if unsupported
seconds amount of seconds in this period, which must be zero if unsupported
millis amount of milliseconds in this period, which must be zero if unsupported
Throws:
java.lang.IllegalArgumentException if an unsupported field's value is non-zero
 
     void setPeriod(int yearsint monthsint weeksint days,
                        int hoursint minutesint secondsint millis);

    
Sets all the fields in one go from an interval dividing the fields using the period type.

Parameters:
interval the interval to set, null means zero length
 
     void setPeriod(ReadableInterval interval);
 
     //-----------------------------------------------------------------------
     
Adds to the value of one of the fields.

The field type specified must be one of those that is supported by the period.

Parameters:
field a DurationFieldType instance that is supported by this period
value the value to add to the field
Throws:
java.lang.IllegalArgumentException if the field is null or not supported
 
     void add(DurationFieldType fieldint value);

    
Adds a period to this one by adding each field in turn.

Parameters:
period the period to add, null means add nothing
Throws:
java.lang.IllegalArgumentException if the period being added contains a field not supported by this period
java.lang.ArithmeticException if the addition exceeds the capacity of the period
    void add(ReadablePeriod period);

    
Adds to each field of this period.

Parameters:
years amount of years to add to this period, which must be zero if unsupported
months amount of months to add to this period, which must be zero if unsupported
weeks amount of weeks to add to this period, which must be zero if unsupported
days amount of days to add to this period, which must be zero if unsupported
hours amount of hours to add to this period, which must be zero if unsupported
minutes amount of minutes to add to this period, which must be zero if unsupported
seconds amount of seconds to add to this period, which must be zero if unsupported
millis amount of milliseconds to add to this period, which must be zero if unsupported
Throws:
java.lang.IllegalArgumentException if the period being added contains a field not supported by this period
java.lang.ArithmeticException if the addition exceeds the capacity of the period
    void add(int yearsint monthsint weeksint days,
                    int hoursint minutesint secondsint millis);

    
Adds an interval to this one by dividing the interval into fields and then adding each field in turn.

Parameters:
interval the interval to add, null means add nothing
Throws:
java.lang.ArithmeticException if the addition exceeds the capacity of the period
    void add(ReadableInterval interval);
    //-----------------------------------------------------------------------
    
Sets the number of years of the period.

Parameters:
years the number of years
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
    void setYears(int years);

    
Adds the specified years to the number of years in the period.

Parameters:
years the number of years
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
java.lang.ArithmeticException if the addition exceeds the capacity of the period
    void addYears(int years);
    //-----------------------------------------------------------------------
    
Sets the number of months of the period.

Parameters:
months the number of months
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
    void setMonths(int months);

    
Adds the specified months to the number of months in the period.

Parameters:
months the number of months
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
java.lang.ArithmeticException if the addition exceeds the capacity of the period
    void addMonths(int months);
    //-----------------------------------------------------------------------
    
Sets the number of weeks of the period.

Parameters:
weeks the number of weeks
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
    void setWeeks(int weeks);

    
Adds the specified weeks to the number of weeks in the period.

Parameters:
weeks the number of weeks
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
java.lang.ArithmeticException if the addition exceeds the capacity of the period
    void addWeeks(int weeks);
    //-----------------------------------------------------------------------
    
Sets the number of days of the period.

Parameters:
days the number of days
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
    void setDays(int days);

    
Adds the specified days to the number of days in the period.

Parameters:
days the number of days
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
java.lang.ArithmeticException if the addition exceeds the capacity of the period
    void addDays(int days);
    //-----------------------------------------------------------------------
    
Sets the number of hours of the period.

Parameters:
hours the number of hours
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
    void setHours(int hours);

    
Adds the specified hours to the number of hours in the period.

Parameters:
hours the number of hours
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
java.lang.ArithmeticException if the addition exceeds the capacity of the period
    void addHours(int hours);
    //-----------------------------------------------------------------------
    
Sets the number of minutes of the period.

Parameters:
minutes the number of minutes
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
    void setMinutes(int minutes);

    
Adds the specified minutes to the number of minutes in the period.

Parameters:
minutes the number of minutes
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
java.lang.ArithmeticException if the addition exceeds the capacity of the period
    void addMinutes(int minutes);
    //-----------------------------------------------------------------------
    
Sets the number of seconds of the period.

Parameters:
seconds the number of seconds
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
    void setSeconds(int seconds);

    
Adds the specified seconds to the number of seconds in the period.

Parameters:
seconds the number of seconds
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
java.lang.ArithmeticException if the addition exceeds the capacity of the period
    void addSeconds(int seconds);
    //-----------------------------------------------------------------------
    
Sets the number of millis of the period.

Parameters:
millis the number of millis
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
    void setMillis(int millis);

    
Adds the specified millis to the number of millis in the period.

Parameters:
millis the number of millis
Throws:
java.lang.IllegalArgumentException if field is not supported and the value is non-zero
java.lang.ArithmeticException if the addition exceeds the capacity of the period
    void addMillis(int millis);
New to GrepCode? Check out our FAQ X