|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--org.joda.time.AbstractInstant
|
+--org.joda.time.AbstractDateTime
|
+--org.joda.time.MutableDateTime
MutableDateTime is the standard implementation of a modifiable datetime class. It holds the date/time as milliseconds from the Java epoch of 1970-01-01T00:00:00Z.
This class requires a Chronology to be specified. The Chronology determines how the millisecond instant value is converted into the date time fields.
Each individual field can be accessed in two ways:
getHourOfDay()
hourOfDay().get()
| Constructor Summary | |
MutableDateTime()
Constructs a MutableDateTime to the current datetime, as reported by the system clock. |
|
MutableDateTime(java.util.Calendar calendar)
Constructs a MutableDateTime from a Calendar, using its closest mapped chronology and time zone. |
|
MutableDateTime(java.util.Calendar calendar,
Chronology chronology)
Constructs a MutableDateTime from a Calendar, using the supplied chronology. |
|
MutableDateTime(java.util.Calendar calendar,
DateTimeZone zone)
Constructs a MutableDateTime from a Calendar, using its closest mapped chronology against a different time zone. |
|
MutableDateTime(Chronology chronology)
Constructs a MutableDateTime to the current datetime, as reported by the system clock. |
|
MutableDateTime(java.util.Date date)
Constructs a MutableDateTime from a Date, using the ISO chronology, in the default time zone. |
|
MutableDateTime(java.util.Date date,
Chronology chronology)
Constructs a MutableDateTime from a Date, using the supplied chronology. |
|
MutableDateTime(java.util.Date date,
DateTimeZone zone)
Constructs a MutableDateTime from a Date, using the ISO chronology, in the supplied time zone. |
|
MutableDateTime(DateTimeZone zone)
Constructs a MutableDateTime to the current datetime, as reported by the system clock. |
|
MutableDateTime(long millis)
Constructs a MutableDateTime set to the milliseconds from 1970-01-01T00:00:00Z, using the ISO chronology, in the default time zone. |
|
MutableDateTime(long millis,
Chronology chronology)
Constructs a MutableDateTime set to the milliseconds from 1970-01-01T00:00:00Z, using the supplied chronology. |
|
MutableDateTime(long millis,
DateTimeZone zone)
Constructs a MutableDateTime set to the milliseconds from 1970-01-01T00:00:00Z, using the ISO chronology, in the supplied time zone. |
|
MutableDateTime(ReadableInstant instant)
Constructs a MutableDateTime from a ReadableInstant, using its chronology. |
|
MutableDateTime(ReadableInstant instant,
Chronology chronology)
Constructs a MutableDateTime from a ReadableInstant, using the supplied chronology. |
|
MutableDateTime(ReadableInstant instant,
DateTimeZone zone)
Constructs a MutableDateTime from a ReadableInstant, using its chronology against a different time zone. |
|
MutableDateTime(java.lang.String str)
Constructs a MutableDateTime from an ISO formatted String, using the ISO chronology, in the default time zone. |
|
MutableDateTime(java.lang.String str,
Chronology chronology)
Constructs a MutableDateTime from an ISO formatted String, using the supplied chronology. |
|
MutableDateTime(java.lang.String str,
DateTimeZone zone)
Constructs a MutableDateTime from an ISO formatted String, using the ISO chronology, in the supplied time zone. |
|
| Method Summary | |
void |
add(DateTimeField field,
int value)
Add a value to the specified field. |
void |
add(java.lang.Object object)
Add an amount of time to the date. |
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(long millis)
Add an amount of time to the datetime. |
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 |
addWrapped(DateTimeField field,
int value)
Add a value to the specified field, wrapping within that field. |
void |
addYears(int years)
Add a number of years to the date. |
MutableDateTimeFieldProperty |
centuryOfEra()
Get the century of era property. |
java.lang.Object |
clone()
Clone this object. |
MutableDateTime |
copy()
Clone this object without having to cast the returned object. |
protected ReadableInstant |
create(long millis,
Chronology chrono)
Creates a new instance of this class. |
MutableDateTimeFieldProperty |
dayOfMonth()
Get the day of month property. |
MutableDateTimeFieldProperty |
dayOfWeek()
Get the day of week property. |
MutableDateTimeFieldProperty |
dayOfYear()
Get the day of year property. |
MutableDateTimeFieldProperty |
era()
Get the era property. |
Chronology |
getChronology()
Gets the chronology of the datetime. |
protected long |
getDateTimeMillisFromObject(java.lang.Object object)
Extracts a long datetime value from an object. |
protected long |
getDurationMillisFromObject(java.lang.Object object)
Extracts a fixed millisecond duration from an object. |
long |
getMillis()
Gets the milliseconds of the datetime instant from the Java epoch of 1970-01-01T00:00:00Z. |
MutableDateTimeFieldProperty |
hourOfDay()
Get the hour of day field property |
MutableDateTimeFieldProperty |
millisOfDay()
Get the millis of day property |
MutableDateTimeFieldProperty |
millisOfSecond()
Get the millis of second property |
MutableDateTimeFieldProperty |
minuteOfDay()
Get the minute of day property |
MutableDateTimeFieldProperty |
minuteOfHour()
Get the minute of hour field property |
MutableDateTimeFieldProperty |
monthOfYear()
Get the month of year property. |
MutableDateTimeFieldProperty |
secondOfDay()
Get the second of day property |
MutableDateTimeFieldProperty |
secondOfMinute()
Get the second of minute field property |
void |
set(DateTimeField field,
int value)
Set a value in the specified field. |
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 millis)
Set the date from milliseconds. |
void |
setDate(java.lang.Object date)
Set the date from various different types of object. |
void |
setDateTime(int year,
int monthOfYear,
int dayOfMonth,
int hourOfDay,
int minuteOfHour,
int secondOfMinute,
int millisOfSecond)
Set the date and time from fields. |
void |
setDateTime(long millis)
Set the date and time from milliseconds. |
void |
setDateTime(java.lang.Object datetime)
Set the date and time from an object. |
void |
setDateTimeZone(DateTimeZone zone)
Sets the time zone of the datetime via the chronology. |
void |
setDayOfMonth(int dayOfMonth)
Set the day of the month to a value. |
void |
setDayOfWeek(int dayOfWeek)
Set the day of week to a value. |
void |
setDayOfYear(int dayOfYear)
Set the day of year to a value. |
void |
setHourOfDay(int hour)
Set the hour of the day. |
void |
setMillis(long millis)
Set the milliseconds of the datetime. |
void |
setMillis(java.lang.Object object)
Set the number of milliseconds of the datetime. |
void |
setMillisOfDay(int millis)
Set the millis of the day. |
void |
setMillisOfSecond(int millis)
Set the millis of the second. |
void |
setMinuteOfDay(int minute)
Set the minute of the day. |
void |
setMinuteOfHour(int minute)
Set the minute of the hour. |
void |
setMonthOfYear(int month)
Set the month of the year to a value. |
void |
setSecondOfDay(int second)
Set the second of the day. |
void |
setSecondOfMinute(int second)
Set the second of the minute. |
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(java.lang.Object time)
Set the time from an object. |
void |
setWeekOfWeekyear(int weekOfWeekyear)
Set the week of weekyear to a value. |
void |
setWeekyear(int weekyear)
Set the week of the year to a value. |
void |
setYear(int year)
Set the year to a value. |
java.lang.String |
toString()
Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSZ). |
MutableDateTimeFieldProperty |
weekOfWeekyear()
Get the week of a week based year property. |
MutableDateTimeFieldProperty |
weekyear()
Get the year of a week based year property. |
MutableDateTimeFieldProperty |
year()
Get the year property. |
MutableDateTimeFieldProperty |
yearOfCentury()
Get the year of century property. |
MutableDateTimeFieldProperty |
yearOfEra()
Get the year of era property. |
| Methods inherited from class org.joda.time.AbstractInstant |
compareTo, equals, get, getDateTimeZone, hashCode, isAfter, isBefore, isEqual, toCalendar, toCopy, toCopy, toDate, toGregorianCalendar, toInstant |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| 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, toDateTime, toDateTime, toMutableDateTime, toMutableDateTime, toMutableDateTime, toString, toString |
| Methods inherited from interface org.joda.time.ReadableInstant |
compareTo, equals, get, getDateTimeZone, hashCode, isAfter, isBefore, isEqual, toCopy, toCopy, toInstant |
| Constructor Detail |
public MutableDateTime()
default time zone.
public MutableDateTime(DateTimeZone zone)
zone - the time zone, must not be null
java.lang.IllegalArgumentException - if the zone is nullpublic MutableDateTime(Chronology chronology)
chronology - the chronology, must not be null
java.lang.IllegalArgumentException - if the chronology is nullpublic MutableDateTime(long millis)
default time zone.
millis - the milliseconds
public MutableDateTime(long millis,
DateTimeZone zone)
millis - the millisecondszone - the time zone, must not be null
java.lang.IllegalArgumentException - if the zone is null
public MutableDateTime(long millis,
Chronology chronology)
millis - the millisecondschronology - the chronology, must not be null
java.lang.IllegalArgumentException - if the chronology is nullpublic MutableDateTime(ReadableInstant instant)
default time zone.
instant - the ReadableInstant, must not be null
java.lang.IllegalArgumentException - if the instant is null
public MutableDateTime(ReadableInstant instant,
DateTimeZone zone)
instant - the ReadableInstant, must not be nullzone - the time zone, must not be null
java.lang.IllegalArgumentException - if the instant or zone is null
public MutableDateTime(ReadableInstant instant,
Chronology chronology)
instant - the ReadableInstant, must not be nullchronology - the chronology, must not be null
java.lang.IllegalArgumentException - if the instant or chronology is nullpublic MutableDateTime(java.util.Date date)
default time zone.
date - the Date, must not be null
java.lang.IllegalArgumentException - if the date is null
public MutableDateTime(java.util.Date date,
DateTimeZone zone)
date - the Date, must not be nullzone - the time zone, must not be null
java.lang.IllegalArgumentException - if the date or zone is null
public MutableDateTime(java.util.Date date,
Chronology chronology)
date - the Date, must not be nullchronology - the chronology, must not be null
java.lang.IllegalArgumentException - if the date or chronology is nullpublic MutableDateTime(java.util.Calendar calendar)
When converting calendars to chronologies, the constructor is aware of GregorianCalendar and BuddhistCalendar and maps them to the equivalent chronology. Other calendars map to ISOChronology.
calendar - the Calendar, must not be null
java.lang.IllegalArgumentException - if the calendar is null
public MutableDateTime(java.util.Calendar calendar,
DateTimeZone zone)
When converting calendars to chronologies, the constructor is aware of GregorianCalendar and BuddhistCalendar and maps them to the equivalent chronology. Other calendars map to ISOChronology.
calendar - the Calendar, must not be null
java.lang.IllegalArgumentException - if the calendar or zone is null
public MutableDateTime(java.util.Calendar calendar,
Chronology chronology)
calendar - the Calendar, must not be nullchronology - the chronology, must not be null
java.lang.IllegalArgumentException - if the calendar or chronology is null
public MutableDateTime(java.lang.String str)
throws java.text.ParseException
default time zone.
str - the string to parse, must not be null
java.lang.IllegalArgumentException - if the string is null
java.text.ParseException - if parsing fails
public MutableDateTime(java.lang.String str,
DateTimeZone zone)
throws java.text.ParseException
str - the string to parse, must not be nullzone - the time zone, must not be null
java.lang.IllegalArgumentException - if the string or zone is null
java.text.ParseException - if parsing fails
public MutableDateTime(java.lang.String str,
Chronology chronology)
throws java.text.ParseException
str - the string to parse, must not be nullchronology - the chronology, must not be null
java.lang.IllegalArgumentException - if the string or chronology is null
java.text.ParseException - if parsing fails| Method Detail |
protected ReadableInstant create(long millis,
Chronology chrono)
The returned object will be a new instance of the implementation.
Immutable subclasses may return this if appropriate.
create in class AbstractInstantmillis - the new millis, from 1970-01-01T00:00:00Zchrono - the new chronology
java.lang.IllegalArgumentException - if the chronology is nullpublic long getMillis()
getMillis in interface ReadableInstantpublic void setMillis(long millis)
setMillis in interface ReadWritableInstantmillis - the milliseconds since 1970-01-01T00:00:00Z to set the
datetime to
public void setMillis(java.lang.Object object)
setMillis in interface ReadWritableInstantjava.lang.IllegalArgumentException - if the object is null
java.lang.ClassCastException - if the object's type cannot be recognisedpublic void add(java.lang.Object object)
add in interface ReadWritableInstantobject - a ReadableDuration, Long or String evaluating to a
durationpublic void addMillis(long millis)
addMillis in interface ReadWritableInstantmillis - the millis to addpublic Chronology getChronology()
getChronology in interface ReadableInstantpublic void setChronology(Chronology chronology)
chronology - the chronology to use
java.lang.IllegalArgumentException - if the chronology is nullpublic void setDateTimeZone(DateTimeZone zone)
zone - the time zone to use
java.lang.IllegalArgumentException - if the time zone is null
public void set(DateTimeField field,
int value)
MutableDateTime dt = new MutableDateTime(); dt.set(GJChronology.getInstance().year(), 2002);
set in interface ReadWritableInstantfield - the DateTimeField to usevalue - the value
java.lang.NullPointerException - if the field is null
public void add(DateTimeField field,
int value)
MutableDateTime dt = new MutableDateTime(); dt.add(GJChronology.getInstance().year(), 2);
add in interface ReadWritableInstantfield - the DateTimeField to usevalue - the value
java.lang.NullPointerException - if the field is null
public void addWrapped(DateTimeField field,
int value)
MutableDateTime dt = new MutableDateTime(); dt.addWrapped(GJChronology.getInstance().monthOfYear(), 6);
addWrapped in interface ReadWritableInstantfield - the DateTimeField to usevalue - the value
java.lang.NullPointerException - if the field is nullpublic void setDayOfWeek(int dayOfWeek)
dayOfWeek - the day of the week.public void setDayOfMonth(int dayOfMonth)
dayOfMonth - the day of the month.public void setDayOfYear(int dayOfYear)
dayOfYear - the day of the year.public void addDays(int days)
days - the days to add.public void setWeekOfWeekyear(int weekOfWeekyear)
weekOfWeekyear - the week of the weekyear.public void addWeeks(int weeks)
weeks - the weeks to add.public void setWeekyear(int weekyear)
weekyear - the weekyear.public void addWeekyears(int weekyears)
weekyears - the weekyears to add.public void setMonthOfYear(int month)
month - the month of the year.public void addMonths(int months)
months - the months to add.public void setYear(int year)
year - the year.public void addYears(int years)
years - the years to add.public void setMillisOfSecond(int millis)
millis - the millis of second.public void setMillisOfDay(int millis)
millis - the millis of day.public void setSecondOfMinute(int second)
second - the second of minute.public void setSecondOfDay(int second)
second - the second of day.public void addSeconds(int seconds)
seconds - the seconds to add.public void setMinuteOfHour(int minute)
minute - the minute of hour.public void setMinuteOfDay(int minute)
minute - the minute of day.public void addMinutes(int minutes)
minutes - the minutes to add.public void setHourOfDay(int hour)
hour - the hour of day.public void addHours(int hours)
hours - the hours to add.public void setDate(java.lang.Object date)
date - a ReadableInstant, Date, Calendar, Long or String
java.lang.IllegalArgumentException - if the object is null.
java.lang.ClassCastException - if the object's type cannot be recognisedpublic void setDate(long millis)
millis - milliseconds from 1970-01-01T00:00:00Z, ignoring time of
day
public void setDate(int year,
int monthOfYear,
int dayOfMonth)
year - the yeardayOfMonth - the day of the monthpublic void setTime(java.lang.Object time)
time - a ReadableInstant, Date, Calendar, Long or String
java.lang.IllegalArgumentException - if the object is null.
java.lang.ClassCastException - if the object's type cannot be recognisedpublic void setTime(long millis)
millis - milliseconds from T00:00:00Z, ignoring date
public void setTime(int hour,
int minuteOfHour,
int secondOfMinute,
int millisOfSecond)
hour - the hourminuteOfHour - the minute of the hoursecondOfMinute - the second of the minutemillisOfSecond - the milisecond of the secondpublic void setDateTime(java.lang.Object datetime)
datetime - a ReadableInstant, Date, Calendar, Long or String
java.lang.IllegalArgumentException - if the object is null.
java.lang.ClassCastException - if the object's type cannot be recognisedpublic void setDateTime(long millis)
millis - the millis
public void setDateTime(int year,
int monthOfYear,
int dayOfMonth,
int hourOfDay,
int minuteOfHour,
int secondOfMinute,
int millisOfSecond)
year - the yeardayOfMonth - the day of the monthminuteOfHour - the minute of the hoursecondOfMinute - the second of the minutemillisOfSecond - the milisecond of the secondpublic MutableDateTimeFieldProperty dayOfWeek()
The values for day of week are defined in DateTimeConstants.
public MutableDateTimeFieldProperty dayOfMonth()
public MutableDateTimeFieldProperty dayOfYear()
public MutableDateTimeFieldProperty weekOfWeekyear()
public MutableDateTimeFieldProperty weekyear()
public MutableDateTimeFieldProperty monthOfYear()
public MutableDateTimeFieldProperty year()
public MutableDateTimeFieldProperty yearOfEra()
public MutableDateTimeFieldProperty yearOfCentury()
public MutableDateTimeFieldProperty centuryOfEra()
public MutableDateTimeFieldProperty era()
public MutableDateTimeFieldProperty millisOfSecond()
public MutableDateTimeFieldProperty millisOfDay()
public MutableDateTimeFieldProperty secondOfMinute()
public MutableDateTimeFieldProperty secondOfDay()
public MutableDateTimeFieldProperty minuteOfHour()
public MutableDateTimeFieldProperty minuteOfDay()
public MutableDateTimeFieldProperty hourOfDay()
public java.lang.String toString()
toString in interface ReadableInstanttoString in class AbstractDateTimepublic MutableDateTime copy()
public java.lang.Object clone()
clone in class java.lang.Objectprotected long getDateTimeMillisFromObject(java.lang.Object object)
object - an input object
java.lang.IllegalArgumentException - if the object is null, or the string invalid
java.lang.ClassCastException - if the object type is not supportedprotected long getDurationMillisFromObject(java.lang.Object object)
object - Long or String
java.lang.IllegalArgumentException - if the object is null, or the string invalid
java.lang.ClassCastException - if the object type is not supported
|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||