Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  Copyright 2001-2010 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.joda.time;
 
 import java.util.Date;
 import java.util.List;
 
 import  org.joda.convert.FromString;
 import  org.joda.convert.ToString;
MonthDay is an immutable partial supporting the monthOfYear and dayOfMonth fields.

NOTE: This class only supports the two fields listed above. It is impossible to query any other fields, such as dayOfWeek or centuryOfEra.

Calculations on MonthDay are performed using a Chronology. This chronology is set to be in the UTC time zone for all calculations.

One use case for this class is to store a birthday without the year (to avoid storing the age of the person). This class can be used as the gMonthDay type in XML Schema.

Each individual field can be queried in two ways:

  • getMonthOfYear()
  • monthOfYear().get()
The second technique also provides access to other useful methods on the field:
  • numeric value - monthOfYear().get()
  • text value - monthOfYear().getAsText()
  • short text value - monthOfYear().getAsShortText()
  • maximum/minimum values - monthOfYear().getMaximumValue()
  • add/subtract - monthOfYear().addToCopy()
  • set - monthOfYear().setCopy()

MonthDay is thread-safe and immutable, provided that the Chronology is as well. All standard Chronology classes supplied are thread-safe and immutable.

Author(s):
Chris Pheby
Since:
2.0
 
 public final class MonthDay
         extends BasePartial
         implements ReadablePartialSerializable {

    
Serialization version
 
     private static final long serialVersionUID = 2954560699050434609L;

    
The singleton set of field types
 
     private static final DateTimeFieldType[] FIELD_TYPES = new DateTimeFieldType[] {
         DateTimeFieldType.monthOfYear(),
         DateTimeFieldType.dayOfMonth(), };

    
The singleton set of field types
 
     private static final DateTimeFormatter PARSER = new DateTimeFormatterBuilder()
         .appendOptional(ISODateTimeFormat.localDateParser().getParser())
         .appendOptional(DateTimeFormat.forPattern("--MM-dd").getParser()).toFormatter();

    
The index of the monthOfYear field in the field array
 
     public static final int MONTH_OF_YEAR = 0;
    
The index of the day field in the field array
 
     public static final int DAY_OF_MONTH = 1;
 
     //-----------------------------------------------------------------------
     
Obtains a MonthDay set to the current system millisecond time using ISOChronology in the default time zone. The resulting object does not use the zone.

Returns:
the current month-day, not null
Since:
2.0
    public static MonthDay now() {
        return new MonthDay();
    }

    
Obtains a MonthDay set to the current system millisecond time using ISOChronology in the specified time zone. The resulting object does not use the zone.

Parameters:
zone the time zone, not null
Returns:
the current month-day, not null
Since:
2.0
    public static MonthDay now(DateTimeZone zone) {
        if (zone == null) {
            throw new NullPointerException("Zone must not be null");
        }
        return new MonthDay(zone);
    }

    
Obtains a MonthDay set to the current system millisecond time using the specified chronology. The resulting object does not use the zone.

Parameters:
chronology the chronology, not null
Returns:
the current month-day, not null
Since:
2.0
    public static MonthDay now(Chronology chronology) {
        if (chronology == null) {
            throw new NullPointerException("Chronology must not be null");
        }
        return new MonthDay(chronology);
    }
    //-----------------------------------------------------------------------
    
Parses a MonthDay from the specified string.

This uses ISODateTimeFormat.localDateParser() or the format --MM-dd.

Parameters:
str the string to parse, not null
Since:
2.0
    @FromString
    public static MonthDay parse(String str) {
        return parse(str);
    }

    
Parses a MonthDay from the specified string using a formatter.

Parameters:
str the string to parse, not null
formatter the formatter to use, not null
Since:
2.0
    public static MonthDay parse(String strDateTimeFormatter formatter) {
        LocalDate date = formatter.parseLocalDate(str);
        return new MonthDay(date.getMonthOfYear(), date.getDayOfMonth());
    }
    //-----------------------------------------------------------------------
    
Constructs a MonthDay from a java.util.Calendar using exactly the same field values avoiding any time zone effects.

Each field is queried from the Calendar and assigned to the MonthDay.

This factory method ignores the type of the calendar and always creates a MonthDay with ISO chronology. It is expected that you will only pass in instances of GregorianCalendar however this is not validated.

Parameters:
calendar the Calendar to extract fields from
Returns:
the created MonthDay, never null
Throws:
IllegalArgumentException if the calendar is null
IllegalArgumentException if the monthOfYear or dayOfMonth is invalid for the ISO chronology
    public static MonthDay fromCalendarFields(Calendar calendar) {
        if (calendar == null) {
            throw new IllegalArgumentException("The calendar must not be null");
        }
        return new MonthDay(calendar.get(.) + 1, calendar.get(.));
    }

    
Constructs a MonthDay from a java.util.Date using exactly the same field values avoiding any time zone effects.

Each field is queried from the Date and assigned to the MonthDay.

This factory method always creates a MonthDay with ISO chronology.

Parameters:
date the Date to extract fields from
Returns:
the created MonthDay, never null
Throws:
IllegalArgumentException if the calendar is null
IllegalArgumentException if the monthOfYear or dayOfMonth is invalid for the ISO chronology
    @SuppressWarnings("deprecation")
    public static MonthDay fromDateFields(Date date) {
        if (date == null) {
            throw new IllegalArgumentException("The date must not be null");
        }
        return new MonthDay(date.getMonth() + 1, date.getDate());
    }
    //-----------------------------------------------------------------------
    
Constructs a MonthDay with the current monthOfYear, using ISOChronology in the default zone to extract the fields.

The constructor uses the default time zone, resulting in the local time being initialised. Once the constructor is complete, all further calculations are performed without reference to a time-zone (by switching to UTC).

See also:
now()
    public MonthDay() {
        super();
    }

    
Constructs a MonthDay with the current month-day, using ISOChronology in the specified zone to extract the fields.

The constructor uses the specified time zone to obtain the current month-day. Once the constructor is complete, all further calculations are performed without reference to a time-zone (by switching to UTC).

Parameters:
zone the zone to use, null means default zone
See also:
now(DateTimeZone)
    public MonthDay(DateTimeZone zone) {
        super(ISOChronology.getInstance(zone));
    }

    
Constructs a MonthDay with the current month-day, using the specified chronology and zone to extract the fields.

The constructor uses the time zone of the chronology specified. Once the constructor is complete, all further calculations are performed without reference to a time-zone (by switching to UTC).

Parameters:
chronology the chronology, null means ISOChronology in the default zone
See also:
now(Chronology)
    public MonthDay(Chronology chronology) {
        super(chronology);
    }

    
Constructs a MonthDay extracting the partial fields from the specified milliseconds using the ISOChronology in the default zone.

The constructor uses the default time zone, resulting in the local time being initialised. Once the constructor is complete, all further calculations are performed without reference to a time-zone (by switching to UTC).

Parameters:
instant the milliseconds from 1970-01-01T00:00:00Z
    public MonthDay(long instant) {
        super(instant);
    }

    
Constructs a MonthDay extracting the partial fields from the specified milliseconds using the chronology provided.

The constructor uses the time zone of the chronology specified. Once the constructor is complete, all further calculations are performed without reference to a time-zone (by switching to UTC).

Parameters:
instant the milliseconds from 1970-01-01T00:00:00Z
chronology the chronology, null means ISOChronology in the default zone
    public MonthDay(long instantChronology chronology) {
        super(instantchronology);
    }

    
Constructs a MonthDay from an Object that represents some form of time.

The recognised object types are defined in ConverterManager and include ReadableInstant, String, Calendar and Date. The String formats are described by ISODateTimeFormat.localDateParser().

The chronology used will be derived from the object, defaulting to ISO.

Parameters:
instant the date-time object, null means now
Throws:
IllegalArgumentException if the instant is invalid
    public MonthDay(Object instant) {
        super(instantnull, ISODateTimeFormat.localDateParser());
    }

    
Constructs a MonthDay from an Object that represents some form of time, using the specified chronology.

The recognised object types are defined in ConverterManager and include ReadableInstant, String, Calendar and Date. The String formats are described by ISODateTimeFormat.localDateParser().

The constructor uses the time zone of the chronology specified. Once the constructor is complete, all further calculations are performed without reference to a time-zone (by switching to UTC). The specified chronology overrides that of the object.

Parameters:
instant the date-time object, null means now
chronology the chronology, null means ISO default
Throws:
IllegalArgumentException if the instant is invalid
    public MonthDay(Object instantChronology chronology) {
        super(instant, DateTimeUtils.getChronology(chronology), ISODateTimeFormat.localDateParser());
    }

    
Constructs a MonthDay with specified year and month using ISOChronology.

The constructor uses the no time zone initialising the fields as provided. Once the constructor is complete, all further calculations are performed without reference to a time-zone (by switching to UTC).

Parameters:
monthOfYear the month of the year
dayOfMonth the day of the month
    public MonthDay(int monthOfYearint dayOfMonth) {
        this(monthOfYeardayOfMonthnull);
    }

    
Constructs an instance set to the specified monthOfYear and dayOfMonth using the specified chronology, whose zone is ignored.

If the chronology is null, ISOChronology is used.

The constructor uses the time zone of the chronology specified. Once the constructor is complete, all further calculations are performed without reference to a time-zone (by switching to UTC).

Parameters:
monthOfYear the month of the year
dayOfMonth the day of the month
chronology the chronology, null means ISOChronology in the default zone
    public MonthDay(int monthOfYearint dayOfMonthChronology chronology) {
        super(new int[] {monthOfYeardayOfMonth}, chronology);
    }

    
Constructs a MonthDay with chronology from this instance and new values.

Parameters:
partial the partial to base this new instance on
values the new set of values
    MonthDay(MonthDay partialint[] values) {
        super(partialvalues);
    }

    
Constructs a MonthDay with values from this instance and a new chronology.

Parameters:
partial the partial to base this new instance on
chrono the new chronology
    MonthDay(MonthDay partialChronology chrono) {
        super(partialchrono);
    }

    
Handle broken serialization from other tools.

Returns:
the resolved object, not null
    private Object readResolve() {
        if (..equals(getChronology().getZone()) == false) {
            return new MonthDay(thisgetChronology().withUTC());
        }
        return this;
    }
    //-----------------------------------------------------------------------
    
Gets the number of fields in this partial, which is two. The supported fields are MonthOfYear and DayOfMonth. Note that only these fields may be queried.

Returns:
the field count, two
    public int size() {
        return 2;
    }

    
Gets the field for a specific index in the chronology specified.

This method must not use any instance variables.

Parameters:
index the index to retrieve
chrono the chronology to use
Returns:
the field, never null
    protected DateTimeField getField(int indexChronology chrono) {
        switch (index) {
        case :
            return chrono.monthOfYear();
        case :
            return chrono.dayOfMonth();
        default:
            throw new IndexOutOfBoundsException("Invalid index: " + index);
        }
    }

    
Gets the field type at the specified index.

Parameters:
index the index to retrieve
Returns:
the field at the specified index, never null
Throws:
IndexOutOfBoundsException if the index is invalid
    public DateTimeFieldType getFieldType(int index) {
        return [index];
    }

    
Gets an array of the field type of each of the fields that this partial supports.

The fields are returned largest to smallest, Month, Day.

Returns:
the array of field types (cloned), largest to smallest, never null
    public DateTimeFieldType[] getFieldTypes() {
        return (DateTimeFieldType[]) .clone();
    }
    //-----------------------------------------------------------------------
    
Returns a copy of this month-day with the specified chronology. This instance is immutable and unaffected by this method call.

This method retains the values of the fields, thus the result will typically refer to a different instant.

The time zone of the specified chronology is ignored, as MonthDay operates without a time zone.

Parameters:
newChronology the new chronology, null means ISO
Returns:
a copy of this month-day with a different chronology, never null
Throws:
IllegalArgumentException if the values are invalid for the new chronology
    public MonthDay withChronologyRetainFields(Chronology newChronology) {
        newChronology = DateTimeUtils.getChronology(newChronology);
        newChronology = newChronology.withUTC();
        if (newChronology == getChronology()) {
            return this;
        } else {
            MonthDay newMonthDay = new MonthDay(thisnewChronology);
            newChronology.validate(newMonthDaygetValues());
            return newMonthDay;
        }
    }

    
Returns a copy of this month-day with the specified field set to a new value.

For example, if the field type is dayOfMonth then the day would be changed in the returned instance.

These three lines are equivalent:

 MonthDay updated = md.withField(DateTimeFieldType.dayOfMonth(), 6);
 MonthDay updated = md.dayOfMonth().setCopy(6);
 MonthDay updated = md.property(DateTimeFieldType.dayOfMonth()).setCopy(6);
 

Parameters:
fieldType the field type to set, not null
value the value to set
Returns:
a copy of this instance with the field set, never null
Throws:
IllegalArgumentException if the value is null or invalid
    public MonthDay withField(DateTimeFieldType fieldTypeint value) {
        int index = indexOfSupported(fieldType);
        if (value == getValue(index)) {
            return this;
        }
        int[] newValues = getValues();
        newValues = getField(index).set(thisindexnewValuesvalue);
        return new MonthDay(thisnewValues);
    }

    
Returns a copy of this month-day with the value of the specified field increased.

If the addition is zero, then this is returned.

These three lines are equivalent:

 MonthDay added = md.withFieldAdded(DurationFieldType.days(), 6);
 MonthDay added = md.plusDays(6);
 MonthDay added = md.dayOfMonth().addToCopy(6);
 

Parameters:
fieldType the field type to add to, not null
amount the amount to add
Returns:
a copy of this instance with the field updated, never null
Throws:
IllegalArgumentException if the value is null or invalid
ArithmeticException if the new date-time exceeds the capacity
    public MonthDay withFieldAdded(DurationFieldType fieldTypeint amount) {
        int index = indexOfSupported(fieldType);
        if (amount == 0) {
            return this;
        }
        int[] newValues = getValues();
        newValues = getField(index).add(thisindexnewValuesamount);
        return new MonthDay(thisnewValues);
    }

    
Returns a copy of this month-day with the specified period added.

If the addition is zero, then this is returned. Fields in the period that aren't present in the partial are ignored.

This method is typically used to add multiple copies of complex period instances. Adding one field is best achieved using methods like withFieldAdded(DurationFieldType, int) or plusMonths(int).

Parameters:
period the period to add to this one, null means zero
scalar the amount of times to add, such as -1 to subtract once
Returns:
a copy of this instance with the period added, never null
Throws:
ArithmeticException if the new date-time exceeds the capacity
    public MonthDay withPeriodAdded(ReadablePeriod periodint scalar) {
        if (period == null || scalar == 0) {
            return this;
        }
        int[] newValues = getValues();
        for (int i = 0; i < period.size(); i++) {
            DurationFieldType fieldType = period.getFieldType(i);
            int index = indexOf(fieldType);
            if (index >= 0) {
                newValues = getField(index).add(thisindexnewValues,
                        FieldUtils.safeMultiply(period.getValue(i), scalar));
            }
        }
        return new MonthDay(thisnewValues);
    }
    //-----------------------------------------------------------------------
    
Returns a copy of this month-day with the specified period added.

If the amount is zero or null, then this is returned.

This method is typically used to add complex period instances. Adding one field is best achieved using methods like plusMonths(int).

Parameters:
period the duration to add to this one, null means zero
Returns:
a copy of this instance with the period added, never null
Throws:
ArithmeticException if the new month-day exceeds the capacity
    public MonthDay plus(ReadablePeriod period) {
        return withPeriodAdded(period, 1);
    }
    //-----------------------------------------------------------------------
    
Returns a copy of this month-day plus the specified number of months.

This month-day instance is immutable and unaffected by this method call. The month will wrap at the end of the year from December to January. The day will be adjusted to the last valid value if necessary.

The following three lines are identical in effect:

 MonthDay added = md.plusMonths(6);
 MonthDay added = md.plus(Period.months(6));
 MonthDay added = md.withFieldAdded(DurationFieldType.months(), 6);
 

Parameters:
months the amount of months to add, may be negative
Returns:
the new month-day plus the increased months, never null
    public MonthDay plusMonths(int months) {
        return withFieldAdded(DurationFieldType.months(), months);
    }

    
Returns a copy of this month-day plus the specified number of days.

This month-day instance is immutable and unaffected by this method call. The month will wrap at the end of the year from December to January.

The following three lines are identical in effect:

 MonthDay added = md.plusDays(6);
 MonthDay added = md.plus(Period.days(6));
 MonthDay added = md.withFieldAdded(DurationFieldType.days(), 6);
 

Parameters:
days the amount of days to add, may be negative
Returns:
the new month-day plus the increased days, never null
    public MonthDay plusDays(int days) {
        return withFieldAdded(DurationFieldType.days(), days);
    }
    //-----------------------------------------------------------------------
    
Returns a copy of this month-day with the specified period taken away.

If the amount is zero or null, then this is returned.

This method is typically used to subtract complex period instances. Subtracting one field is best achieved using methods like minusMonths(int).

Parameters:
period the period to reduce this instant by
Returns:
a copy of this instance with the period taken away, never null
Throws:
ArithmeticException if the new month-day exceeds the capacity
    public MonthDay minus(ReadablePeriod period) {
        return withPeriodAdded(period, -1);
    }
    //-----------------------------------------------------------------------
    
Returns a copy of this month-day minus the specified number of months.

This MonthDay instance is immutable and unaffected by this method call. The month will wrap at the end of the year from January to December. The day will be adjusted to the last valid value if necessary.

The following three lines are identical in effect:

 MonthDay subtracted = md.minusMonths(6);
 MonthDay subtracted = md.minus(Period.months(6));
 MonthDay subtracted = md.withFieldAdded(DurationFieldType.months(), -6);
 

Parameters:
months the amount of months to subtract, may be negative
Returns:
the new month-day minus the increased months, never null
    public MonthDay minusMonths(int months) {
        return withFieldAdded(DurationFieldType.months(), FieldUtils.safeNegate(months));
    }

    
Returns a copy of this month-day minus the specified number of months.

This month-day instance is immutable and unaffected by this method call. The month will wrap at the end of the year from January to December.

The following three lines are identical in effect:

 MonthDay subtracted = md.minusDays(6);
 MonthDay subtracted = md.minus(Period.days(6));
 MonthDay subtracted = md.withFieldAdded(DurationFieldType.days(), -6);
 

Parameters:
days the amount of days to subtract, may be negative
Returns:
the new month-day minus the increased days, never null
    public MonthDay minusDays(int days) {
        return withFieldAdded(DurationFieldType.days(), FieldUtils.safeNegate(days));
    }
    //-----------------------------------------------------------------------
    
Converts this object to a LocalDate with the same month-day and chronology.

Parameters:
year the year to use, valid for chronology
Returns:
a LocalDate with the same month-day and chronology, never null
    public LocalDate toLocalDate(int year) {
        return new LocalDate(yeargetMonthOfYear(), getDayOfMonth(), getChronology());
    }
    //-----------------------------------------------------------------------
    
Get the month of year field value.

Returns:
the month of year
    public int getMonthOfYear() {
        return getValue();
    }

    
Get the day of month field value.

Returns:
the day of month
    public int getDayOfMonth() {
        return getValue();
    }
    //-----------------------------------------------------------------------
    
Returns a copy of this month-day with the month of year field updated.

MonthDay is immutable, so there are no set methods. Instead, this method returns a new instance with the value of month of year changed.

Parameters:
monthOfYear the month of year to set
Returns:
a copy of this object with the field set, never null
Throws:
IllegalArgumentException if the value is invalid
    public MonthDay withMonthOfYear(int monthOfYear) {
        int[] newValues = getValues();
        newValues = getChronology().monthOfYear().set(thisnewValuesmonthOfYear);
        return new MonthDay(thisnewValues);
    }

    
Returns a copy of this month-day with the day of month field updated.

MonthDay is immutable, so there are no set methods. Instead, this method returns a new instance with the value of day of month changed.

Parameters:
dayOfMonth the day of month to set
Returns:
a copy of this object with the field set, never null
Throws:
IllegalArgumentException if the value is invalid
    public MonthDay withDayOfMonth(int dayOfMonth) {
        int[] newValues = getValues();
        newValues = getChronology().dayOfMonth().set(thisnewValuesdayOfMonth);
        return new MonthDay(thisnewValues);
    }
    //-----------------------------------------------------------------------
    
Gets the property object for the specified type, which contains many useful methods.

Parameters:
type the field type to get the property for
Returns:
the property object
Throws:
IllegalArgumentException if the field is null or unsupported
    public Property property(DateTimeFieldType type) {
        return new Property(thisindexOfSupported(type));
    }
    //-----------------------------------------------------------------------
    
Get the month of year field property which provides access to advanced functionality.

Returns:
the month of year property
    public Property monthOfYear() {
        return new Property(this);
    }

    
Get the day of month field property which provides access to advanced functionality.

Returns:
the day of month property
    public Property dayOfMonth() {
        return new Property(this);
    }
    //-----------------------------------------------------------------------
    
Output the month-day in ISO8601 format (--MM-dd).

Returns:
ISO8601 time formatted string.
    @ToString
    public String toString() {
        List<DateTimeFieldTypefields = new ArrayList<DateTimeFieldType>();
        fields.add(DateTimeFieldType.monthOfYear());
        fields.add(DateTimeFieldType.dayOfMonth());
        return ISODateTimeFormat.forFields(fieldstruetrue).print(this);
    }

    
Output the month-day using the specified format pattern.

Parameters:
pattern the pattern specification, null means use toString
See also:
org.joda.time.format.DateTimeFormat
    public String toString(String pattern) {
        if (pattern == null) {
            return toString();
        }
        return DateTimeFormat.forPattern(pattern).print(this);
    }

    
Output the month-day using the specified format pattern.

Parameters:
pattern the pattern specification, null means use toString
locale Locale to use, null means default
See also:
org.joda.time.format.DateTimeFormat
    public String toString(String patternLocale localethrows IllegalArgumentException {
        if (pattern == null) {
            return toString();
        }
        return DateTimeFormat.forPattern(pattern).withLocale(locale).print(this);
    }
    //-----------------------------------------------------------------------
    
The property class for MonthDay.

This class binds a YearMonth to a DateTimeField.

Author(s):
Chris Pheby
Since:
2.0
    public static class Property extends AbstractPartialFieldProperty implements Serializable {

        
Serialization version
        private static final long serialVersionUID = 5727734012190224363L;

        
The partial
        private final MonthDay iBase;
        
The field index
        private final int iFieldIndex;

        
Constructs a property.

Parameters:
partial the partial instance
fieldIndex the index in the partial
        Property(MonthDay partialint fieldIndex) {
            super();
             = partial;
             = fieldIndex;
        }

        
Gets the field that this property uses.

Returns:
the field
        public DateTimeField getField() {
            return .getField();
        }

        
Gets the partial that this property belongs to.

Returns:
the partial
        protected ReadablePartial getReadablePartial() {
            return ;
        }

        
Gets the partial that this property belongs to.

Returns:
the partial
        public MonthDay getMonthDay() {
            return ;
        }

        
Gets the value of this field.

Returns:
the field value
        public int get() {
            return .getValue();
        }
        //-----------------------------------------------------------------------
        
Adds to the value of this field in a copy of this MonthDay.

The value will be added to this field. If the value is too large to be added solely to this field then it will affect larger fields. Smaller fields are unaffected.

The MonthDay attached to this property is unchanged by this call. Instead, a new instance is returned.

Parameters:
valueToAdd the value to add to the field in the copy
Returns:
a copy of the MonthDay with the field value changed
Throws:
IllegalArgumentException if the value isn't valid
        public MonthDay addToCopy(int valueToAdd) {
            int[] newValues = .getValues();
            newValues = getField().add(newValuesvalueToAdd);
            return new MonthDay(newValues);
        }

        
Adds to the value of this field in a copy of this MonthDay wrapping within this field if the maximum value is reached.

The value will be added to this field. If the value is too large to be added solely to this field then it wraps within this field. Other fields are unaffected.

For example, --12-30 addWrapField one month returns --01-30.

The MonthDay attached to this property is unchanged by this call. Instead, a new instance is returned.

Parameters:
valueToAdd the value to add to the field in the copy
Returns:
a copy of the MonthDay with the field value changed
Throws:
IllegalArgumentException if the value isn't valid
        public MonthDay addWrapFieldToCopy(int valueToAdd) {
            int[] newValues = .getValues();
            newValues = getField().addWrapField(newValuesvalueToAdd);
            return new MonthDay(newValues);
        }
        //-----------------------------------------------------------------------
        
Sets this field in a copy of the MonthDay.

The MonthDay attached to this property is unchanged by this call. Instead, a new instance is returned.

Parameters:
value the value to set the field in the copy to
Returns:
a copy of the MonthDay with the field value changed
Throws:
IllegalArgumentException if the value isn't valid
        public MonthDay setCopy(int value) {
            int[] newValues = .getValues();
            newValues = getField().set(newValuesvalue);
            return new MonthDay(newValues);
        }

        
Sets this field in a copy of the MonthDay to a parsed text value.

The MonthDay attached to this property is unchanged by this call. Instead, a new instance is returned.

Parameters:
text the text value to set
locale optional locale to use for selecting a text symbol
Returns:
a copy of the MonthDay with the field value changed
Throws:
IllegalArgumentException if the text value isn't valid
        public MonthDay setCopy(String textLocale locale) {
            int[] newValues = .getValues();
            newValues = getField().set(newValuestextlocale);
            return new MonthDay(newValues);
        }

        
Sets this field in a copy of the MonthDay to a parsed text value.

The MonthDay attached to this property is unchanged by this call. Instead, a new instance is returned.

Parameters:
text the text value to set
Returns:
a copy of the MonthDay with the field value changed
Throws:
IllegalArgumentException if the text value isn't valid
        public MonthDay setCopy(String text) {
            return setCopy(textnull);
        }
    }
New to GrepCode? Check out our FAQ X