org.joda.time

Class MutableDateTime

Implemented Interfaces:
Cloneable, Comparable, ReadableDateTime, ReadableInstant, ReadWritableDateTime, ReadWritableInstant, Serializable

public class MutableDateTime
extends BaseDateTime
implements ReadWritableDateTime, Cloneable, 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 ISOChronology which is the agreed international standard and compatable with the modern Gregorian calendar.

Each individual field can be accessed in two ways:

The second technique also provides access to other useful methods on the field:

MutableDateTime is mutable and not thread-safe, unless concurrent threads are not invoking mutator methods.

Authors:
Guy Allard
Brian S O'Neill
Stephen Colebourne
Mike Schrag
Since:
1.0
See Also:
DateTime

Nested Class Summary

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

Field Summary

static int
ROUND_CEILING
Rounding mode as described by DateTimeField.roundCeiling(long)
static int
ROUND_FLOOR
Rounding mode as described by DateTimeField.roundFloor(long)
static int
ROUND_HALF_CEILING
Rounding mode as described by DateTimeField.roundHalfCeiling(long)
static int
ROUND_HALF_EVEN
Rounding mode as described by DateTimeField.roundHalfEven(long)
static int
ROUND_HALF_FLOOR
Rounding mode as described by DateTimeField.roundHalfFloor(long)
static int
ROUND_NONE
Rounding is disabled

Constructor Summary

MutableDateTime()
Constructs an instance set to the current system millisecond time using ISOChronology in the default time zone.
MutableDateTime(Object instant)
Constructs an instance from an Object that represents a datetime.
MutableDateTime(Object instant, Chronology chronology)
Constructs an instance from an Object that represents a datetime, using the specified chronology.
MutableDateTime(Object instant, DateTimeZone zone)
Constructs an instance from an Object that represents a datetime, forcing the time zone to that specified.
MutableDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)
Constructs an instance from datetime field values using ISOChronology in 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 using ISOChronology in the specified time zone.
MutableDateTime(long instant)
Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using ISOChronology in 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 using ISOChronology in the specified time zone.
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 using ISOChronology in the specified time zone.

Method Summary

void
add(long duration)
Add an amount of time to the datetime.
void
add(DurationFieldType type, int amount)
Adds to the instant specifying the duration and multiple to add.
void
add(ReadableDuration duration)
Adds a duration to this instant.
void
add(ReadableDuration duration, int scalar)
Adds a duration to this instant specifying how many times to add.
void
add(ReadablePeriod period)
Adds a period to this instant.
void
add(ReadablePeriod period, int scalar)
Adds a period to this instant specifying how many times to add.
void
addDays(int days)
Add a number of days to the date.
void
addHours(int hours)
Add a number of hours to the date.
void
addMillis(int millis)
Add a number of milliseconds to the date.
void
addMinutes(int minutes)
Add a number of minutes to the date.
void
addMonths(int months)
Add a number of months to the date.
void
addSeconds(int seconds)
Add a number of seconds to the date.
void
addWeeks(int weeks)
Add a number of weeks to the date.
void
addWeekyears(int weekyears)
Add a number of weekyears to the date.
void
addYears(int years)
Add a number of years to the date.
MutableDateTime.Property
centuryOfEra()
Get the century of era property.
Object
clone()
Clone this object.
MutableDateTime
copy()
Clone this object without having to cast the returned object.
MutableDateTime.Property
dayOfMonth()
Get the day of month property.
MutableDateTime.Property
dayOfWeek()
Get the day of week property.
MutableDateTime.Property
dayOfYear()
Get the day of year property.
MutableDateTime.Property
era()
Get the era property.
DateTimeField
getRoundingField()
Gets the field used for rounding this instant, returning null if rounding is not enabled.
int
getRoundingMode()
Gets the rounding mode for this instant, returning ROUND_NONE if rounding is not enabled.
MutableDateTime.Property
hourOfDay()
Get the hour of day field property
MutableDateTime.Property
millisOfDay()
Get the millis of day property
MutableDateTime.Property
millisOfSecond()
Get the millis of second property
MutableDateTime.Property
minuteOfDay()
Get the minute of day property
MutableDateTime.Property
minuteOfHour()
Get the minute of hour field property
MutableDateTime.Property
monthOfYear()
Get the month of year property.
MutableDateTime.Property
property(DateTimeFieldType type)
Gets the property object for the specified type, which contains many useful methods.
MutableDateTime.Property
secondOfDay()
Get the second of day property
MutableDateTime.Property
secondOfMinute()
Get the second of minute field property
void
set(DateTimeFieldType type, int value)
Sets the value of one of the fields of the instant, such as hourOfDay.
void
setChronology(Chronology chronology)
Set the chronology of the datetime.
void
setDate(int year, int monthOfYear, int dayOfMonth)
Set the date from fields.
void
setDate(long instant)
Set the date from milliseconds.
void
setDate(ReadableInstant instant)
Set the date from another instant.
void
setDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)
Set the date and time from fields.
void
setDayOfMonth(int dayOfMonth)
Set the day of the month to the specified value.
void
setDayOfWeek(int dayOfWeek)
Set the day of week to the specified value.
void
setDayOfYear(int dayOfYear)
Set the day of year to the specified value.
void
setHourOfDay(int hourOfDay)
Set the hour of the day to the specified value.
void
setMillis(long instant)
Set the milliseconds of the datetime.
void
setMillis(ReadableInstant instant)
Sets the millisecond instant of this instant from another.
void
setMillisOfDay(int millisOfDay)
Set the millis of the day to the specified value.
void
setMillisOfSecond(int millisOfSecond)
Set the millis of the second to the specified value.
void
setMinuteOfDay(int minuteOfDay)
Set the minute of the day to the specified value.
void
setMinuteOfHour(int minuteOfHour)
Set the minute of the hour to the specified value.
void
setMonthOfYear(int monthOfYear)
Set the month of the year to the specified value.
void
setRounding(DateTimeField field)
Sets the status of rounding to use the specified field and ROUND_FLOOR mode.
void
setRounding(DateTimeField field, int mode)
Sets the status of rounding to use the specified field and mode.
void
setSecondOfDay(int secondOfDay)
Set the second of the day to the specified value.
void
setSecondOfMinute(int secondOfMinute)
Set the second of the minute to the specified value.
void
setTime(int hour, int minuteOfHour, int secondOfMinute, int millisOfSecond)
Set the time from fields.
void
setTime(long millis)
Set the time from milliseconds.
void
setTime(ReadableInstant instant)
Set the time from another instant.
void
setWeekOfWeekyear(int weekOfWeekyear)
Set the week of weekyear to the specified value.
void
setWeekyear(int weekyear)
Set the weekyear to the specified value.
void
setYear(int year)
Set the year to the specified value.
void
setZone(DateTimeZone newZone)
Sets the time zone of the datetime, changing the chronology and field values.
void
setZoneRetainFields(DateTimeZone newZone)
Sets the time zone of the datetime, changing the chronology and millisecond.
String
toString()
Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSZZ).
MutableDateTime.Property
weekOfWeekyear()
Get the week of a week based year property.
MutableDateTime.Property
weekyear()
Get the year of a week based year property.
MutableDateTime.Property
year()
Get the year property.
MutableDateTime.Property
yearOfCentury()
Get the year of century property.
MutableDateTime.Property
yearOfEra()
Get the year of era property.

Methods inherited from class org.joda.time.base.BaseDateTime

checkChronology, checkInstant, getChronology, getMillis, setChronology, setMillis

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

Methods inherited from class org.joda.time.base.AbstractInstant

compareTo, equals, get, get, getZone, hashCode, isAfter, isAfter, isAfterNow, isBefore, isBefore, isBeforeNow, isEqual, isEqual, isEqualNow, isSupported, toDate, toDateTime, toDateTime, toDateTime, toDateTimeISO, toInstant, toMutableDateTime, toMutableDateTime, toMutableDateTime, toMutableDateTimeISO, toString, toString

Field Details

ROUND_CEILING

public static final int ROUND_CEILING
Field Value:
2

ROUND_FLOOR

public static final int ROUND_FLOOR
Field Value:
1

ROUND_HALF_CEILING

public static final int ROUND_HALF_CEILING
Field Value:
4

ROUND_HALF_EVEN

public static final int ROUND_HALF_EVEN
Field Value:
5

ROUND_HALF_FLOOR

public static final int ROUND_HALF_FLOOR
Field Value:
3

ROUND_NONE

public static final int ROUND_NONE
Rounding is disabled
Field Value:
0

Constructor Details

MutableDateTime

public MutableDateTime()
Constructs an instance set to the current system millisecond time using ISOChronology in the default time zone.

MutableDateTime

public MutableDateTime(Object instant)
Parameters:
instant - the datetime object, null means now

MutableDateTime

public MutableDateTime(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 ConverterManager and include ReadableInstant, String, Calendar and Date.

Parameters:
instant - the datetime object, null means now
chronology - the chronology, null means ISOChronology in default zone

MutableDateTime

public MutableDateTime(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 ConverterManager and include ReadableInstant, String, Calendar and Date.

Parameters:
instant - the datetime object, null means now
zone - 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)
Constructs an instance from datetime field values using ISOChronology in the default time zone.
Parameters:
year - the year
monthOfYear - the month of the year
dayOfMonth - the day of the month
hourOfDay - the hour of the day
minuteOfHour - the minute of the hour
secondOfMinute - the second of the minute
millisOfSecond - the millisecond of the second

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, ISOChronology in the default time zone is used.

Parameters:
year - the year
monthOfYear - the month of the year
dayOfMonth - the day of the month
hourOfDay - the hour of the day
minuteOfHour - the minute of the hour
secondOfMinute - the second of the minute
millisOfSecond - the millisecond of the second
chronology - the chronology, null means ISOChronology in default zone

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 using ISOChronology in the specified time zone.

If the specified time zone is null, the default zone is used.

Parameters:
year - the year
monthOfYear - the month of the year
dayOfMonth - the day of the month
hourOfDay - the hour of the day
minuteOfHour - the minute of the hour
secondOfMinute - the second of the minute
millisOfSecond - the millisecond of the second
zone - the time zone, null means default time zone

MutableDateTime

public MutableDateTime(long instant)
Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using ISOChronology in the default time zone.
Parameters:
instant - the milliseconds from 1970-01-01T00:00:00Z

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, ISOChronology in the default time zone is used.

Parameters:
instant - the milliseconds from 1970-01-01T00:00:00Z
chronology - the chronology, null means ISOChronology in default zone

MutableDateTime

public MutableDateTime(long instant,
                       DateTimeZone zone)
Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z using ISOChronology in 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:00Z
zone - the time zone, null means default zone

MutableDateTime

public MutableDateTime(Chronology chronology)
Constructs an instance set to the current system millisecond time using the specified chronology.

If the chronology is null, ISOChronology in the default time zone is used.

Parameters:
chronology - the chronology, null means ISOChronology in default zone

MutableDateTime

public MutableDateTime(DateTimeZone zone)
Constructs an instance set to the current system millisecond time using ISOChronology in 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

Method Details

add

public void add(long duration)
Add an amount of time to the datetime.
Specified by:
add in interface ReadWritableInstant
Parameters:
duration - the millis to add

add

public void add(DurationFieldType type,
                int amount)
Adds to the instant specifying the duration and multiple to add.
Specified by:
add in interface ReadWritableInstant
Parameters:
type - a field type, usually obtained from DateTimeFieldType, not null
amount - the amount to add of this duration

add

public void add(ReadableDuration duration)
Adds a duration to this instant.

This will typically change the value of most fields.

Specified by:
add in interface ReadWritableInstant
Parameters:
duration - the duration to add, null means add zero

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:
add in interface ReadWritableInstant
Parameters:
duration - the duration to add, null means add zero
scalar - direction and amount to add, which may be negative

add

public void add(ReadablePeriod period)
Adds a period to this instant.

This will typically change the value of most fields.

Specified by:
add in interface ReadWritableInstant
Parameters:
period - the period to add, null means add zero

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:
add in interface ReadWritableInstant
Parameters:
period - the period to add, null means add zero
scalar - direction and amount to add, which may be negative

addDays

public void addDays(int days)
Add a number of days to the date.
Specified by:
addDays in interface ReadWritableDateTime
Parameters:
days - the days to add

addHours

public void addHours(int hours)
Add a number of hours to the date.
Specified by:
addHours in interface ReadWritableDateTime
Parameters:
hours - the hours to add

addMillis

public void addMillis(int millis)
Specified by:
addMillis in interface ReadWritableDateTime
Parameters:
millis - the milliseconds to add

addMinutes

public void addMinutes(int minutes)
Add a number of minutes to the date.
Specified by:
addMinutes in interface ReadWritableDateTime
Parameters:
minutes - the minutes to add

addMonths

public void addMonths(int months)
Add a number of months to the date.
Specified by:
addMonths in interface ReadWritableDateTime
Parameters:
months - the months to add

addSeconds

public void addSeconds(int seconds)
Add a number of seconds to the date.
Specified by:
addSeconds in interface ReadWritableDateTime
Parameters:
seconds - the seconds to add

addWeeks

public void addWeeks(int weeks)
Add a number of weeks to the date.
Specified by:
addWeeks in interface ReadWritableDateTime
Parameters:
weeks - the weeks to add

addWeekyears

public void addWeekyears(int weekyears)
Add a number of weekyears to the date.
Specified by:
addWeekyears in interface ReadWritableDateTime
Parameters:
weekyears - the weekyears to add

addYears

public void addYears(int years)
Add a number of years to the date.
Specified by:
addYears in interface ReadWritableDateTime
Parameters:
years - the years to add

centuryOfEra

public MutableDateTime.Property centuryOfEra()
Get the century of era property.
Returns:
the year of era property

clone

public Object clone()
Clone this object.
Returns:
a clone of this object.

copy

public MutableDateTime copy()
Clone this object without having to cast the returned object.
Returns:
a clone of the this object.

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

dayOfYear

public MutableDateTime.Property dayOfYear()
Get the day of year property.
Returns:
the day of year property

era

public MutableDateTime.Property era()
Get the era property.
Returns:
the era property

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

hourOfDay

public MutableDateTime.Property hourOfDay()
Get the hour of day field property
Returns:
the hour of day property

millisOfDay

public MutableDateTime.Property millisOfDay()
Get the millis of day property
Returns:
the millis of day property

millisOfSecond

public MutableDateTime.Property millisOfSecond()
Get the millis of second property
Returns:
the millis of second property

minuteOfDay

public MutableDateTime.Property minuteOfDay()
Get the minute of day property
Returns:
the minute of day property

minuteOfHour

public MutableDateTime.Property minuteOfHour()
Get the minute of hour field property
Returns:
the minute of hour property

monthOfYear

public MutableDateTime.Property monthOfYear()
Get the month of year property.
Returns:
the month of year property

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
Since:
1.2

secondOfDay

public MutableDateTime.Property secondOfDay()
Get the second of day property
Returns:
the second of day property

secondOfMinute

public MutableDateTime.Property secondOfMinute()
Get the second of minute field property
Returns:
the second of minute property

set

public void set(DateTimeFieldType type,
                int value)
Sets the value of one of the fields of the instant, such as hourOfDay.
Specified by:
set in interface ReadWritableInstant
Parameters:
type - a field type, usually obtained from DateTimeFieldType, not null
value - the value to set the field to

setChronology

public void setChronology(Chronology chronology)
Set the chronology of the datetime.

All changes to the chronology occur via this method.

Specified by:
setChronology in interface ReadWritableInstant
Overrides:
setChronology in interface BaseDateTime
Parameters:
chronology - the chronology to use, null means ISOChronology in default zone

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:
setDate in interface ReadWritableDateTime
Parameters:
year - the year
monthOfYear - the month of the year
dayOfMonth - the day of the month

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

setDate

public void setDate(ReadableInstant instant)
Set the date from another instant. The time part of this object will be unaffected.
Parameters:
instant - an instant to copy the date from, time part ignored

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:
setDateTime in interface ReadWritableDateTime
Parameters:
year - the year
monthOfYear - the month of the year
dayOfMonth - the day of the month
hourOfDay - the hour of the day
minuteOfHour - the minute of the hour
secondOfMinute - the second of the minute
millisOfSecond - the millisecond of the second

setDayOfMonth

public void setDayOfMonth(int dayOfMonth)
Set the day of the month to the specified value.
Specified by:
setDayOfMonth in interface ReadWritableDateTime
Parameters:
dayOfMonth - the day of the month

setDayOfWeek

public void setDayOfWeek(int dayOfWeek)
Set the day of week to the specified value.
Specified by:
setDayOfWeek in interface ReadWritableDateTime
Parameters:
dayOfWeek - the day of the week

setDayOfYear

public void setDayOfYear(int dayOfYear)
Set the day of year to the specified value.
Specified by:
setDayOfYear in interface ReadWritableDateTime
Parameters:
dayOfYear - the day of the year

setHourOfDay

public void setHourOfDay(int hourOfDay)
Set the hour of the day to the specified value.
Specified by:
setHourOfDay in interface ReadWritableDateTime
Parameters:
hourOfDay - the hour of day

setMillis

public void setMillis(long instant)
Set the milliseconds of the datetime.

All changes to the millisecond field occurs via this method.

Specified by:
setMillis in interface ReadWritableInstant
Overrides:
setMillis in interface BaseDateTime
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:
setMillis in interface ReadWritableInstant
Parameters:
instant - the instant to use, null means now

setMillisOfDay

public void setMillisOfDay(int millisOfDay)
Set the millis of the day to the specified value.
Specified by:
setMillisOfDay in interface ReadWritableDateTime
Parameters:
millisOfDay - the millis of day

setMillisOfSecond

public void setMillisOfSecond(int millisOfSecond)
Set the millis of the second to the specified value.
Specified by:
setMillisOfSecond in interface ReadWritableDateTime
Parameters:
millisOfSecond - the millis of second

setMinuteOfDay

public void setMinuteOfDay(int minuteOfDay)
Set the minute of the day to the specified value.
Specified by:
setMinuteOfDay in interface ReadWritableDateTime
Parameters:
minuteOfDay - the minute of day

setMinuteOfHour

public void setMinuteOfHour(int minuteOfHour)
Set the minute of the hour to the specified value.
Specified by:
setMinuteOfHour in interface ReadWritableDateTime
Parameters:
minuteOfHour - the minute of hour

setMonthOfYear

public void setMonthOfYear(int monthOfYear)
Set the month of the year to the specified value.
Specified by:
setMonthOfYear in interface ReadWritableDateTime
Parameters:
monthOfYear - the month of the year

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 disable
mode - rounding mode or ROUND_NONE to disable

setSecondOfDay

public void setSecondOfDay(int secondOfDay)
Set the second of the day to the specified value.
Specified by:
setSecondOfDay in interface ReadWritableDateTime
Parameters:
secondOfDay - the second of day

setSecondOfMinute

public void setSecondOfMinute(int secondOfMinute)
Set the second of the minute to the specified value.
Specified by:
setSecondOfMinute in interface ReadWritableDateTime
Parameters:
secondOfMinute - the second of minute

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:
setTime in interface ReadWritableDateTime
Parameters:
hour - the hour
minuteOfHour - the minute of the hour
secondOfMinute - the second of the minute
millisOfSecond - the millisecond of the second

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

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

setWeekOfWeekyear

public void setWeekOfWeekyear(int weekOfWeekyear)
Set the week of weekyear to the specified value.
Specified by:
setWeekOfWeekyear in interface ReadWritableDateTime
Parameters:
weekOfWeekyear - the week of the weekyear

setWeekyear

public void setWeekyear(int weekyear)
Set the weekyear to the specified value.
Specified by:
setWeekyear in interface ReadWritableDateTime
Parameters:
weekyear - the weekyear

setYear

public void setYear(int year)
Set the year to the specified value.
Specified by:
setYear in interface ReadWritableDateTime
Parameters:
year - the year

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:
setZone in interface ReadWritableInstant
Parameters:
newZone - the time zone to use, null means default zone

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:
setZoneRetainFields in interface ReadWritableInstant
Parameters:
newZone - the time zone to use, null means default zone

toString

public String toString()
Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSZZ).
Specified by:
toString in interface ReadableInstant
Overrides:
toString in interface AbstractInstant
Returns:
ISO8601 time formatted string.

weekOfWeekyear

public MutableDateTime.Property weekOfWeekyear()
Get the week of a week based year property.
Returns:
the week of a week based 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

year

public MutableDateTime.Property year()
Get the year property.
Returns:
the year 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

Copyright (c) 2001-2006 - Joda.org