Class MutableDateTime
- java.lang.Object
 - 
- org.joda.time.base.AbstractInstant
 - 
- org.joda.time.base.AbstractDateTime
 - 
- org.joda.time.base.BaseDateTime
 - 
- org.joda.time.MutableDateTime
 
 
 
 
 
- 
- All Implemented Interfaces:
 java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<ReadableInstant>,ReadableDateTime,ReadableInstant,ReadWritableDateTime,ReadWritableInstant
public class MutableDateTime extends BaseDateTime implements ReadWritableDateTime, java.lang.Cloneable, java.io.Serializable
MutableDateTime is the standard implementation of a modifiable datetime class. It holds the datetime as milliseconds from the Java epoch of 1970-01-01T00:00:00Z.This class uses a Chronology internally. The Chronology determines how the millisecond instant value is converted into the date time fields. The default Chronology is
ISOChronologywhich is the agreed international standard and compatible with the modern Gregorian calendar.Each individual field can be accessed in two ways:
getHourOfDay()hourOfDay().get()
- get numeric value
 - set numeric value
 - add to numeric value
 - add to numeric value wrapping with the field
 - get text value
 - get short text value
 - set text value
 - field maximum value
 - field minimum value
 
MutableDateTime is mutable and not thread-safe, unless concurrent threads are not invoking mutator methods.
- Since:
 - 1.0
 - See Also:
 DateTime, Serialized Form
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMutableDateTime.PropertyMutableDateTime.Property binds a MutableDateTime to a DateTimeField allowing powerful datetime functionality to be easily accessed. 
- 
Field Summary
Fields Modifier and Type Field Description static intROUND_CEILINGRounding mode as described byDateTimeField.roundCeiling(long)static intROUND_FLOORRounding mode as described byDateTimeField.roundFloor(long)static intROUND_HALF_CEILINGRounding mode as described byDateTimeField.roundHalfCeiling(long)static intROUND_HALF_EVENRounding mode as described byDateTimeField.roundHalfEven(long)static intROUND_HALF_FLOORRounding mode as described byDateTimeField.roundHalfFloor(long)static intROUND_NONERounding is disabled 
- 
Constructor Summary
Constructors Constructor Description MutableDateTime()Constructs an instance set to the current system millisecond time usingISOChronologyin the default time zone.MutableDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)Constructs an instance from datetime field values usingISOChronologyin the default time zone.MutableDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond, Chronology chronology)Constructs an instance from datetime field values using the specified chronology.MutableDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond, DateTimeZone zone)Constructs an instance from datetime field values usingISOChronologyin the specified time zone.MutableDateTime(long instant)Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z usingISOChronologyin the default time zone.MutableDateTime(long instant, Chronology chronology)Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using the specified chronology.MutableDateTime(long instant, DateTimeZone zone)Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z usingISOChronologyin the specified time zone.MutableDateTime(java.lang.Object instant)Constructs an instance from an Object that represents a datetime.MutableDateTime(java.lang.Object instant, Chronology chronology)Constructs an instance from an Object that represents a datetime, using the specified chronology.MutableDateTime(java.lang.Object instant, DateTimeZone zone)Constructs an instance from an Object that represents a datetime, forcing the time zone to that specified.MutableDateTime(Chronology chronology)Constructs an instance set to the current system millisecond time using the specified chronology.MutableDateTime(DateTimeZone zone)Constructs an instance set to the current system millisecond time usingISOChronologyin the specified time zone. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(long duration)Add an amount of time to the datetime.voidadd(DurationFieldType type, int amount)Adds to the instant specifying the duration and multiple to add.voidadd(ReadableDuration duration)Adds a duration to this instant.voidadd(ReadableDuration duration, int scalar)Adds a duration to this instant specifying how many times to add.voidadd(ReadablePeriod period)Adds a period to this instant.voidadd(ReadablePeriod period, int scalar)Adds a period to this instant specifying how many times to add.voidaddDays(int days)Add a number of days to the date.voidaddHours(int hours)Add a number of hours to the date.voidaddMillis(int millis)Add a number of milliseconds to the date.voidaddMinutes(int minutes)Add a number of minutes to the date.voidaddMonths(int months)Add a number of months to the date.voidaddSeconds(int seconds)Add a number of seconds to the date.voidaddWeeks(int weeks)Add a number of weeks to the date.voidaddWeekyears(int weekyears)Add a number of weekyears to the date.voidaddYears(int years)Add a number of years to the date.MutableDateTime.PropertycenturyOfEra()Get the century of era property.java.lang.Objectclone()Clone this object.MutableDateTimecopy()Clone this object without having to cast the returned object.MutableDateTime.PropertydayOfMonth()Get the day of month property.MutableDateTime.PropertydayOfWeek()Get the day of week property.MutableDateTime.PropertydayOfYear()Get the day of year property.MutableDateTime.Propertyera()Get the era property.DateTimeFieldgetRoundingField()Gets the field used for rounding this instant, returning null if rounding is not enabled.intgetRoundingMode()Gets the rounding mode for this instant, returning ROUND_NONE if rounding is not enabled.MutableDateTime.PropertyhourOfDay()Get the hour of day field propertyMutableDateTime.PropertymillisOfDay()Get the millis of day propertyMutableDateTime.PropertymillisOfSecond()Get the millis of second propertyMutableDateTime.PropertyminuteOfDay()Get the minute of day propertyMutableDateTime.PropertyminuteOfHour()Get the minute of hour field propertyMutableDateTime.PropertymonthOfYear()Get the month of year property.static MutableDateTimenow()Obtains aMutableDateTimeset to the current system millisecond time usingISOChronologyin the default time zone.static MutableDateTimenow(Chronology chronology)Obtains aMutableDateTimeset to the current system millisecond time using the specified chronology.static MutableDateTimenow(DateTimeZone zone)Obtains aMutableDateTimeset to the current system millisecond time usingISOChronologyin the specified time zone.static MutableDateTimeparse(java.lang.String str)Parses aMutableDateTimefrom the specified string.static MutableDateTimeparse(java.lang.String str, DateTimeFormatter formatter)Parses aMutableDateTimefrom the specified string using a formatter.MutableDateTime.Propertyproperty(DateTimeFieldType type)Gets the property object for the specified type, which contains many useful methods.MutableDateTime.PropertysecondOfDay()Get the second of day propertyMutableDateTime.PropertysecondOfMinute()Get the second of minute field propertyvoidset(DateTimeFieldType type, int value)Sets the value of one of the fields of the instant, such as hourOfDay.voidsetChronology(Chronology chronology)Set the chronology of the datetime.voidsetDate(int year, int monthOfYear, int dayOfMonth)Set the date from fields.voidsetDate(long instant)Set the date from milliseconds.voidsetDate(ReadableInstant instant)Set the date from another instant.voidsetDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)Set the date and time from fields.voidsetDayOfMonth(int dayOfMonth)Set the day of the month to the specified value.voidsetDayOfWeek(int dayOfWeek)Set the day of week to the specified value.voidsetDayOfYear(int dayOfYear)Set the day of year to the specified value.voidsetHourOfDay(int hourOfDay)Set the hour of the day to the specified value.voidsetMillis(long instant)Set the milliseconds of the datetime.voidsetMillis(ReadableInstant instant)Sets the millisecond instant of this instant from another.voidsetMillisOfDay(int millisOfDay)Set the millis of the day to the specified value.voidsetMillisOfSecond(int millisOfSecond)Set the millis of the second to the specified value.voidsetMinuteOfDay(int minuteOfDay)Set the minute of the day to the specified value.voidsetMinuteOfHour(int minuteOfHour)Set the minute of the hour to the specified value.voidsetMonthOfYear(int monthOfYear)Set the month of the year to the specified value.voidsetRounding(DateTimeField field)Sets the status of rounding to use the specified field and ROUND_FLOOR mode.voidsetRounding(DateTimeField field, int mode)Sets the status of rounding to use the specified field and mode.voidsetSecondOfDay(int secondOfDay)Set the second of the day to the specified value.voidsetSecondOfMinute(int secondOfMinute)Set the second of the minute to the specified value.voidsetTime(int hour, int minuteOfHour, int secondOfMinute, int millisOfSecond)Set the time from fields.voidsetTime(long millis)Set the time from milliseconds.voidsetTime(ReadableInstant instant)Set the time from another instant.voidsetWeekOfWeekyear(int weekOfWeekyear)Set the week of weekyear to the specified value.voidsetWeekyear(int weekyear)Set the weekyear to the specified value.voidsetYear(int year)Set the year to the specified value.voidsetZone(DateTimeZone newZone)Sets the time zone of the datetime, changing the chronology and field values.voidsetZoneRetainFields(DateTimeZone newZone)Sets the time zone of the datetime, changing the chronology and millisecond.MutableDateTime.PropertyweekOfWeekyear()Get the week of a week based year property.MutableDateTime.Propertyweekyear()Get the year of a week based year property.MutableDateTime.Propertyyear()Get the year property.MutableDateTime.PropertyyearOfCentury()Get the year of century property.MutableDateTime.PropertyyearOfEra()Get the year of era property.- 
Methods inherited from class org.joda.time.base.BaseDateTime
getChronology, getMillis 
- 
Methods inherited from class org.joda.time.base.AbstractDateTime
get, getCenturyOfEra, getDayOfMonth, getDayOfWeek, getDayOfYear, getEra, getHourOfDay, getMillisOfDay, getMillisOfSecond, getMinuteOfDay, getMinuteOfHour, getMonthOfYear, getSecondOfDay, getSecondOfMinute, getWeekOfWeekyear, getWeekyear, getYear, getYearOfCentury, getYearOfEra, toCalendar, toGregorianCalendar, toString, toString, toString 
- 
Methods inherited from class org.joda.time.base.AbstractInstant
compareTo, equals, get, getZone, hashCode, isAfter, isAfter, isAfterNow, isBefore, isBefore, isBeforeNow, isEqual, isEqual, isEqualNow, isSupported, toDate, toDateTime, toDateTime, toDateTime, toDateTimeISO, toInstant, toMutableDateTime, toMutableDateTime, toMutableDateTime, toMutableDateTimeISO, toString 
- 
Methods inherited from interface org.joda.time.ReadableDateTime
getCenturyOfEra, getDayOfMonth, getDayOfWeek, getDayOfYear, getEra, getHourOfDay, getMillisOfDay, getMillisOfSecond, getMinuteOfDay, getMinuteOfHour, getMonthOfYear, getSecondOfDay, getSecondOfMinute, getWeekOfWeekyear, getWeekyear, getYear, getYearOfCentury, getYearOfEra, toDateTime, toMutableDateTime, toString, toString 
- 
Methods inherited from interface org.joda.time.ReadableInstant
equals, get, getChronology, getMillis, getZone, hashCode, isAfter, isBefore, isEqual, isSupported, toInstant, toString 
 - 
 
 - 
 
- 
- 
Field Detail
- 
ROUND_NONE
public static final int ROUND_NONE
Rounding is disabled- See Also:
 - Constant Field Values
 
 
- 
ROUND_FLOOR
public static final int ROUND_FLOOR
Rounding mode as described byDateTimeField.roundFloor(long)- See Also:
 - Constant Field Values
 
 
- 
ROUND_CEILING
public static final int ROUND_CEILING
Rounding mode as described byDateTimeField.roundCeiling(long)- See Also:
 - Constant Field Values
 
 
- 
ROUND_HALF_FLOOR
public static final int ROUND_HALF_FLOOR
Rounding mode as described byDateTimeField.roundHalfFloor(long)- See Also:
 - Constant Field Values
 
 
- 
ROUND_HALF_CEILING
public static final int ROUND_HALF_CEILING
Rounding mode as described byDateTimeField.roundHalfCeiling(long)- See Also:
 - Constant Field Values
 
 
- 
ROUND_HALF_EVEN
public static final int ROUND_HALF_EVEN
Rounding mode as described byDateTimeField.roundHalfEven(long)- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Constructor Detail
- 
MutableDateTime
public MutableDateTime()
Constructs an instance set to the current system millisecond time usingISOChronologyin the default time zone.- See Also:
 now()
 
- 
MutableDateTime
public MutableDateTime(DateTimeZone zone)
Constructs an instance set to the current system millisecond time usingISOChronologyin the specified time zone.If the specified time zone is null, the default zone is used.
- Parameters:
 zone- the time zone, null means default zone- See Also:
 now(DateTimeZone)
 
- 
MutableDateTime
public MutableDateTime(Chronology chronology)
Constructs an instance set to the current system millisecond time using the specified chronology.If the chronology is null,
ISOChronologyin the default time zone is used.- Parameters:
 chronology- the chronology, null means ISOChronology in default zone- See Also:
 now(Chronology)
 
- 
MutableDateTime
public MutableDateTime(long instant)
Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z usingISOChronologyin the default time zone.- Parameters:
 instant- the milliseconds from 1970-01-01T00:00:00Z
 
- 
MutableDateTime
public MutableDateTime(long instant, DateTimeZone zone)Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z usingISOChronologyin the specified time zone.If the specified time zone is null, the default zone is used.
- Parameters:
 instant- the milliseconds from 1970-01-01T00:00:00Zzone- the time zone, null means default zone
 
- 
MutableDateTime
public MutableDateTime(long instant, Chronology chronology)Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using the specified chronology.If the chronology is null,
ISOChronologyin the default time zone is used.- Parameters:
 instant- the milliseconds from 1970-01-01T00:00:00Zchronology- the chronology, null means ISOChronology in default zone
 
- 
MutableDateTime
public MutableDateTime(java.lang.Object instant)
Constructs an instance from an Object that represents a datetime.If the object implies a chronology (such as GregorianCalendar does), then that chronology will be used. Otherwise, ISO default is used. Thus if a GregorianCalendar is passed in, the chronology used will be GJ, but if a Date is passed in the chronology will be ISO.
The recognised object types are defined in
ConverterManagerand include ReadableInstant, String, Calendar and Date.- Parameters:
 instant- the datetime object, null means now- Throws:
 java.lang.IllegalArgumentException- if the instant is invalid
 
- 
MutableDateTime
public MutableDateTime(java.lang.Object instant, DateTimeZone zone)Constructs an instance from an Object that represents a datetime, forcing the time zone to that specified.If the object implies a chronology (such as GregorianCalendar does), then that chronology will be used, but with the time zone adjusted. Otherwise, ISO is used in the specified time zone. If the specified time zone is null, the default zone is used. Thus if a GregorianCalendar is passed in, the chronology used will be GJ, but if a Date is passed in the chronology will be ISO.
The recognised object types are defined in
ConverterManagerand include ReadableInstant, String, Calendar and Date.- Parameters:
 instant- the datetime object, null means nowzone- the time zone, null means default time zone- Throws:
 java.lang.IllegalArgumentException- if the instant is invalid
 
- 
MutableDateTime
public MutableDateTime(java.lang.Object instant, Chronology chronology)Constructs an instance from an Object that represents a datetime, using the specified chronology.If the chronology is null, ISO in the default time zone is used. Any chronology implied by the object (such as GregorianCalendar does) is ignored.
The recognised object types are defined in
ConverterManagerand include ReadableInstant, String, Calendar and Date.- Parameters:
 instant- the datetime object, null means nowchronology- the chronology, null means ISOChronology in default zone- Throws:
 java.lang.IllegalArgumentException- if the instant is invalid
 
- 
MutableDateTime
public MutableDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)Constructs an instance from datetime field values usingISOChronologyin the default time zone.- Parameters:
 year- the yearmonthOfYear- the month of the yeardayOfMonth- the day of the monthhourOfDay- the hour of the dayminuteOfHour- the minute of the hoursecondOfMinute- the second of the minutemillisOfSecond- the millisecond of the second
 
- 
MutableDateTime
public MutableDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond, DateTimeZone zone)Constructs an instance from datetime field values usingISOChronologyin the specified time zone.If the specified time zone is null, the default zone is used.
- Parameters:
 year- the yearmonthOfYear- the month of the yeardayOfMonth- the day of the monthhourOfDay- the hour of the dayminuteOfHour- the minute of the hoursecondOfMinute- the second of the minutemillisOfSecond- the millisecond of the secondzone- the time zone, null means default time zone
 
- 
MutableDateTime
public MutableDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond, Chronology chronology)Constructs an instance from datetime field values using the specified chronology.If the chronology is null,
ISOChronologyin the default time zone is used.- Parameters:
 year- the yearmonthOfYear- the month of the yeardayOfMonth- the day of the monthhourOfDay- the hour of the dayminuteOfHour- the minute of the hoursecondOfMinute- the second of the minutemillisOfSecond- the millisecond of the secondchronology- the chronology, null means ISOChronology in default zone
 
 - 
 
- 
Method Detail
- 
now
public static MutableDateTime now()
Obtains aMutableDateTimeset to the current system millisecond time usingISOChronologyin the default time zone.- Returns:
 - the current date-time, not null
 - Since:
 - 2.0
 
 
- 
now
public static MutableDateTime now(DateTimeZone zone)
Obtains aMutableDateTimeset to the current system millisecond time usingISOChronologyin the specified time zone.- Parameters:
 zone- the time zone, not null- Returns:
 - the current date-time, not null
 - Since:
 - 2.0
 
 
- 
now
public static MutableDateTime now(Chronology chronology)
Obtains aMutableDateTimeset to the current system millisecond time using the specified chronology.- Parameters:
 chronology- the chronology, not null- Returns:
 - the current date-time, not null
 - Since:
 - 2.0
 
 
- 
parse
public static MutableDateTime parse(java.lang.String str)
Parses aMutableDateTimefrom the specified string.This uses
ISODateTimeFormat.dateTimeParser().- Parameters:
 str- the string to parse, not null- Since:
 - 2.0
 
 
- 
parse
public static MutableDateTime parse(java.lang.String str, DateTimeFormatter formatter)
Parses aMutableDateTimefrom the specified string using a formatter.- Parameters:
 str- the string to parse, not nullformatter- the formatter to use, not null- Since:
 - 2.0
 
 
- 
getRoundingField
public DateTimeField getRoundingField()
Gets the field used for rounding this instant, returning null if rounding is not enabled.- Returns:
 - the rounding field
 
 
- 
getRoundingMode
public int getRoundingMode()
Gets the rounding mode for this instant, returning ROUND_NONE if rounding is not enabled.- Returns:
 - the rounding mode constant
 
 
- 
setRounding
public void setRounding(DateTimeField field)
Sets the status of rounding to use the specified field and ROUND_FLOOR mode. A null field will disable rounding. Once set, the instant is then rounded using the new field and mode.Enabling rounding will cause all subsequent calls to
setMillis(long)to be rounded. This can be used to control the precision of the instant, for example by setting a rounding field of minuteOfDay, the seconds and milliseconds will always be zero.- Parameters:
 field- rounding field or null to disable
 
- 
setRounding
public void setRounding(DateTimeField field, int mode)
Sets the status of rounding to use the specified field and mode. A null field or mode of ROUND_NONE will disable rounding. Once set, the instant is then rounded using the new field and mode.Enabling rounding will cause all subsequent calls to
setMillis(long)to be rounded. This can be used to control the precision of the instant, for example by setting a rounding field of minuteOfDay, the seconds and milliseconds will always be zero.- Parameters:
 field- rounding field or null to disablemode- rounding mode or ROUND_NONE to disable- Throws:
 java.lang.IllegalArgumentException- if mode is unknown, no exception if field is null
 
- 
setMillis
public void setMillis(long instant)
Set the milliseconds of the datetime.All changes to the millisecond field occurs via this method.
- Specified by:
 setMillisin interfaceReadWritableInstant- Parameters:
 instant- the milliseconds since 1970-01-01T00:00:00Z to set the datetime to
 
- 
setMillis
public void setMillis(ReadableInstant instant)
Sets the millisecond instant of this instant from another.This method does not change the chronology of this instant, just the millisecond instant.
- Specified by:
 setMillisin interfaceReadWritableInstant- Parameters:
 instant- the instant to use, null means now
 
- 
add
public void add(long duration)
Add an amount of time to the datetime.- Specified by:
 addin interfaceReadWritableInstant- Parameters:
 duration- the millis to add- Throws:
 java.lang.ArithmeticException- if the result exceeds the capacity of the instant
 
- 
add
public void add(ReadableDuration duration)
Adds a duration to this instant.This will typically change the value of most fields.
- Specified by:
 addin interfaceReadWritableInstant- Parameters:
 duration- the duration to add, null means add zero- Throws:
 java.lang.ArithmeticException- if the result exceeds the capacity of the instant
 
- 
add
public void add(ReadableDuration duration, int scalar)
Adds a duration to this instant specifying how many times to add.This will typically change the value of most fields.
- Specified by:
 addin interfaceReadWritableInstant- Parameters:
 duration- the duration to add, null means add zeroscalar- direction and amount to add, which may be negative- Throws:
 java.lang.ArithmeticException- if the result exceeds the capacity of the instant
 
- 
add
public void add(ReadablePeriod period)
Adds a period to this instant.This will typically change the value of most fields.
- Specified by:
 addin interfaceReadWritableInstant- Parameters:
 period- the period to add, null means add zero- Throws:
 java.lang.ArithmeticException- if the result exceeds the capacity of the instant
 
- 
add
public void add(ReadablePeriod period, int scalar)
Adds a period to this instant specifying how many times to add.This will typically change the value of most fields.
- Specified by:
 addin interfaceReadWritableInstant- Parameters:
 period- the period to add, null means add zeroscalar- direction and amount to add, which may be negative- Throws:
 java.lang.ArithmeticException- if the result exceeds the capacity of the instant
 
- 
setChronology
public void setChronology(Chronology chronology)
Set the chronology of the datetime.All changes to the chronology occur via this method.
- Specified by:
 setChronologyin interfaceReadWritableInstant- Parameters:
 chronology- the chronology to use, null means ISOChronology in default zone
 
- 
setZone
public void setZone(DateTimeZone newZone)
Sets the time zone of the datetime, changing the chronology and field values.Changing the zone using this method retains the millisecond instant. The millisecond instant is adjusted in the new zone to compensate. chronology. Setting the time zone does not affect the millisecond value of this instant.
If the chronology already has this time zone, no change occurs.
- Specified by:
 setZonein interfaceReadWritableInstant- Parameters:
 newZone- the time zone to use, null means default zone- See Also:
 setZoneRetainFields(org.joda.time.DateTimeZone)
 
- 
setZoneRetainFields
public void setZoneRetainFields(DateTimeZone newZone)
Sets the time zone of the datetime, changing the chronology and millisecond.Changing the zone using this method retains the field values. The millisecond instant is adjusted in the new zone to compensate.
If the chronology already has this time zone, no change occurs.
- Specified by:
 setZoneRetainFieldsin interfaceReadWritableInstant- Parameters:
 newZone- the time zone to use, null means default zone- See Also:
 setZone(org.joda.time.DateTimeZone)
 
- 
set
public void set(DateTimeFieldType type, int value)
Sets the value of one of the fields of the instant, such as hourOfDay.- Specified by:
 setin interfaceReadWritableInstant- Parameters:
 type- a field type, usually obtained from DateTimeFieldType, not nullvalue- the value to set the field to- Throws:
 java.lang.IllegalArgumentException- if the value is null or invalid
 
- 
add
public void add(DurationFieldType type, int amount)
Adds to the instant specifying the duration and multiple to add.- Specified by:
 addin interfaceReadWritableInstant- Parameters:
 type- a field type, usually obtained from DateTimeFieldType, not nullamount- the amount to add of this duration- Throws:
 java.lang.IllegalArgumentException- if the value is null or invalidjava.lang.ArithmeticException- if the result exceeds the capacity of the instant
 
- 
setYear
public void setYear(int year)
Set the year to the specified value.- Specified by:
 setYearin interfaceReadWritableDateTime- Parameters:
 year- the year- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
addYears
public void addYears(int years)
Add a number of years to the date.- Specified by:
 addYearsin interfaceReadWritableDateTime- Parameters:
 years- the years to add- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setWeekyear
public void setWeekyear(int weekyear)
Set the weekyear to the specified value.- Specified by:
 setWeekyearin interfaceReadWritableDateTime- Parameters:
 weekyear- the weekyear- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
addWeekyears
public void addWeekyears(int weekyears)
Add a number of weekyears to the date.- Specified by:
 addWeekyearsin interfaceReadWritableDateTime- Parameters:
 weekyears- the weekyears to add- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setMonthOfYear
public void setMonthOfYear(int monthOfYear)
Set the month of the year to the specified value.- Specified by:
 setMonthOfYearin interfaceReadWritableDateTime- Parameters:
 monthOfYear- the month of the year- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
addMonths
public void addMonths(int months)
Add a number of months to the date.- Specified by:
 addMonthsin interfaceReadWritableDateTime- Parameters:
 months- the months to add- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setWeekOfWeekyear
public void setWeekOfWeekyear(int weekOfWeekyear)
Set the week of weekyear to the specified value.- Specified by:
 setWeekOfWeekyearin interfaceReadWritableDateTime- Parameters:
 weekOfWeekyear- the week of the weekyear- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
addWeeks
public void addWeeks(int weeks)
Add a number of weeks to the date.- Specified by:
 addWeeksin interfaceReadWritableDateTime- Parameters:
 weeks- the weeks to add- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setDayOfYear
public void setDayOfYear(int dayOfYear)
Set the day of year to the specified value.- Specified by:
 setDayOfYearin interfaceReadWritableDateTime- Parameters:
 dayOfYear- the day of the year- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setDayOfMonth
public void setDayOfMonth(int dayOfMonth)
Set the day of the month to the specified value.- Specified by:
 setDayOfMonthin interfaceReadWritableDateTime- Parameters:
 dayOfMonth- the day of the month- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setDayOfWeek
public void setDayOfWeek(int dayOfWeek)
Set the day of week to the specified value.- Specified by:
 setDayOfWeekin interfaceReadWritableDateTime- Parameters:
 dayOfWeek- the day of the week- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
addDays
public void addDays(int days)
Add a number of days to the date.- Specified by:
 addDaysin interfaceReadWritableDateTime- Parameters:
 days- the days to add- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setHourOfDay
public void setHourOfDay(int hourOfDay)
Set the hour of the day to the specified value.- Specified by:
 setHourOfDayin interfaceReadWritableDateTime- Parameters:
 hourOfDay- the hour of day- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
addHours
public void addHours(int hours)
Add a number of hours to the date.- Specified by:
 addHoursin interfaceReadWritableDateTime- Parameters:
 hours- the hours to add- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setMinuteOfDay
public void setMinuteOfDay(int minuteOfDay)
Set the minute of the day to the specified value.Setting this will replace the values of minute-of-hour and hour-of-day.
- Specified by:
 setMinuteOfDayin interfaceReadWritableDateTime- Parameters:
 minuteOfDay- the minute of day- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setMinuteOfHour
public void setMinuteOfHour(int minuteOfHour)
Set the minute of the hour to the specified value.- Specified by:
 setMinuteOfHourin interfaceReadWritableDateTime- Parameters:
 minuteOfHour- the minute of hour- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
addMinutes
public void addMinutes(int minutes)
Add a number of minutes to the date.- Specified by:
 addMinutesin interfaceReadWritableDateTime- Parameters:
 minutes- the minutes to add- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setSecondOfDay
public void setSecondOfDay(int secondOfDay)
Set the second of the day to the specified value.Setting this will replace the values of second-of-minute, minute-of-hour and hour-of-day.
- Specified by:
 setSecondOfDayin interfaceReadWritableDateTime- Parameters:
 secondOfDay- the second of day- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setSecondOfMinute
public void setSecondOfMinute(int secondOfMinute)
Set the second of the minute to the specified value.- Specified by:
 setSecondOfMinutein interfaceReadWritableDateTime- Parameters:
 secondOfMinute- the second of minute- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
addSeconds
public void addSeconds(int seconds)
Add a number of seconds to the date.- Specified by:
 addSecondsin interfaceReadWritableDateTime- Parameters:
 seconds- the seconds to add- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setMillisOfDay
public void setMillisOfDay(int millisOfDay)
Set the millis of the day to the specified value.Setting this will replace the values of milli-of-second, second-of-minute, minute-of-hour and hour-of-day.
- Specified by:
 setMillisOfDayin interfaceReadWritableDateTime- Parameters:
 millisOfDay- the millis of day- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setMillisOfSecond
public void setMillisOfSecond(int millisOfSecond)
Set the millis of the second to the specified value.- Specified by:
 setMillisOfSecondin interfaceReadWritableDateTime- Parameters:
 millisOfSecond- the millis of second- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
addMillis
public void addMillis(int millis)
Add a number of milliseconds to the date. The implementation of this method differs from theadd(long)method in that a DateTimeField performs the addition.- Specified by:
 addMillisin interfaceReadWritableDateTime- Parameters:
 millis- the milliseconds to add- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setDate
public void setDate(long instant)
Set the date from milliseconds. The time part of this object will be unaffected.- Parameters:
 instant- an instant to copy the date from, time part ignored- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setDate
public void setDate(ReadableInstant instant)
Set the date from another instant. The time part of this object will be unaffected.If the input is a
ReadableDateTimethen it is converted to the same time-zone as this object before using the instant millis.- Parameters:
 instant- an instant to copy the date from, time part ignored- Throws:
 java.lang.IllegalArgumentException- if the object is invalid
 
- 
setDate
public void setDate(int year, int monthOfYear, int dayOfMonth)Set the date from fields. The time part of this object will be unaffected.- Specified by:
 setDatein interfaceReadWritableDateTime- Parameters:
 year- the yearmonthOfYear- the month of the yeardayOfMonth- the day of the month- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setTime
public void setTime(long millis)
Set the time from milliseconds. The date part of this object will be unaffected.- Parameters:
 millis- an instant to copy the time from, date part ignored- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setTime
public void setTime(ReadableInstant instant)
Set the time from another instant. The date part of this object will be unaffected.- Parameters:
 instant- an instant to copy the time from, date part ignored- Throws:
 java.lang.IllegalArgumentException- if the object is invalid
 
- 
setTime
public void setTime(int hour, int minuteOfHour, int secondOfMinute, int millisOfSecond)Set the time from fields. The date part of this object will be unaffected.- Specified by:
 setTimein interfaceReadWritableDateTime- Parameters:
 hour- the hourminuteOfHour- the minute of the hoursecondOfMinute- the second of the minutemillisOfSecond- the millisecond of the second- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
setDateTime
public void setDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)Set the date and time from fields.- Specified by:
 setDateTimein interfaceReadWritableDateTime- Parameters:
 year- the yearmonthOfYear- the month of the yeardayOfMonth- the day of the monthhourOfDay- the hour of the dayminuteOfHour- the minute of the hoursecondOfMinute- the second of the minutemillisOfSecond- the millisecond of the second- Throws:
 java.lang.IllegalArgumentException- if the value is invalid
 
- 
property
public MutableDateTime.Property property(DateTimeFieldType type)
Gets the property object for the specified type, which contains many useful methods.- Parameters:
 type- the field type to get the chronology for- Returns:
 - the property object
 - Throws:
 java.lang.IllegalArgumentException- if the field is null or unsupported- Since:
 - 1.2
 
 
- 
era
public MutableDateTime.Property era()
Get the era property.- Returns:
 - the era property
 
 
- 
centuryOfEra
public MutableDateTime.Property centuryOfEra()
Get the century of era property.- Returns:
 - the year of era property
 
 
- 
yearOfCentury
public MutableDateTime.Property yearOfCentury()
Get the year of century property.- Returns:
 - the year of era property
 
 
- 
yearOfEra
public MutableDateTime.Property yearOfEra()
Get the year of era property.- Returns:
 - the year of era property
 
 
- 
year
public MutableDateTime.Property year()
Get the year property.- Returns:
 - the year property
 
 
- 
weekyear
public MutableDateTime.Property weekyear()
Get the year of a week based year property.- Returns:
 - the year of a week based year property
 
 
- 
monthOfYear
public MutableDateTime.Property monthOfYear()
Get the month of year property.- Returns:
 - the month of year property
 
 
- 
weekOfWeekyear
public MutableDateTime.Property weekOfWeekyear()
Get the week of a week based year property.- Returns:
 - the week of a week based year property
 
 
- 
dayOfYear
public MutableDateTime.Property dayOfYear()
Get the day of year property.- Returns:
 - the day of year property
 
 
- 
dayOfMonth
public MutableDateTime.Property dayOfMonth()
Get the day of month property.The values for day of month are defined in
DateTimeConstants.- Returns:
 - the day of month property
 
 
- 
dayOfWeek
public MutableDateTime.Property dayOfWeek()
Get the day of week property.The values for day of week are defined in
DateTimeConstants.- Returns:
 - the day of week property
 
 
- 
hourOfDay
public MutableDateTime.Property hourOfDay()
Get the hour of day field property- Returns:
 - the hour of day property
 
 
- 
minuteOfDay
public MutableDateTime.Property minuteOfDay()
Get the minute of day propertyCalling a setter on the property will replace the values of minute-of-hour and hour-of-day.
- Returns:
 - the minute of day property
 
 
- 
minuteOfHour
public MutableDateTime.Property minuteOfHour()
Get the minute of hour field property- Returns:
 - the minute of hour property
 
 
- 
secondOfDay
public MutableDateTime.Property secondOfDay()
Get the second of day propertyCalling a setter on the property will replace the values of second-of-minute, minute-of-hour and hour-of-day.
- Returns:
 - the second of day property
 
 
- 
secondOfMinute
public MutableDateTime.Property secondOfMinute()
Get the second of minute field property- Returns:
 - the second of minute property
 
 
- 
millisOfDay
public MutableDateTime.Property millisOfDay()
Get the millis of day propertyCalling a setter on the property will replace the values of milli-of-second, second-of-minute, minute-of-hour and hour-of-day.
- Returns:
 - the millis of day property
 
 
- 
millisOfSecond
public MutableDateTime.Property millisOfSecond()
Get the millis of second property- Returns:
 - the millis of second property
 
 
- 
copy
public MutableDateTime copy()
Clone this object without having to cast the returned object.- Returns:
 - a clone of the this object.
 
 
- 
clone
public java.lang.Object clone()
Clone this object.- Returns:
 - a clone of this object.
 
 
 - 
 
 -