| org.joda.time.base.BaseLocal org.joda.time.LocalDateTime
LocalDateTime | final public class LocalDateTime extends BaseLocal implements ReadablePartial,Serializable(Code) | | LocalDateTime is an unmodifiable datetime class representing a
datetime without a time zone.
LocalDateTime implements the
ReadablePartial interface.
To do this, certain methods focus on key fields Year, MonthOfYear,
DayOfYear and MillisOfDay.
However, all fields may in fact be queried.
Internally, LocalDateTime uses a single millisecond-based value to
represent the local datetime. This value is only used internally and
is not exposed to applications.
Calculations on LocalDateTime are performed using a
Chronology .
This chronology will be set internally to be in the UTC time zone
for all calculations.
Each individual field can be queried in two ways:
getHourOfDay()
hourOfDay().get()
The second technique also provides access to other useful methods on the
field:
- numeric value
- text value
- short text value
- maximum/minimum values
- add/subtract
- set
- rounding
LocalDateTime is thread-safe and immutable, provided that the Chronology is as well.
All standard Chronology classes supplied are thread-safe and immutable.
author: Stephen Colebourne since: 1.3 |
Constructor Summary | |
public | LocalDateTime() Constructs an instance set to the current local time evaluated using
ISO chronology in the default zone. | public | LocalDateTime(DateTimeZone zone) Constructs an instance set to the current local time evaluated using
ISO chronology in the specified zone. | public | LocalDateTime(Chronology chronology) Constructs an instance set to the current local time evaluated using
specified chronology. | public | LocalDateTime(long instant) Constructs an instance set to the local time defined by the specified
instant evaluated using ISO chronology in the default zone. | public | LocalDateTime(long instant, DateTimeZone zone) Constructs an instance set to the local time defined by the specified
instant evaluated using ISO chronology in the specified zone. | public | LocalDateTime(long instant, Chronology chronology) Constructs an instance set to the local time defined by the specified
instant evaluated using the specified chronology. | public | LocalDateTime(Object instant) Constructs an instance from an Object that represents a datetime. | public | LocalDateTime(Object instant, DateTimeZone zone) Constructs an instance from an Object that represents a datetime,
forcing the time zone to that specified. | public | LocalDateTime(Object instant, Chronology chronology) Constructs an instance from an Object that represents a datetime,
using the specified chronology. | public | LocalDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour) Constructs an instance set to the specified date and time
using ISOChronology . | public | LocalDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute) Constructs an instance set to the specified date and time
using ISOChronology . | public | LocalDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) Constructs an instance set to the specified date and time
using ISOChronology . | public | LocalDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond, Chronology chronology) Constructs an instance set to the specified date and time
using the specified chronology, whose zone is ignored. |
Method Summary | |
public Property | centuryOfEra() Get the century of era property which provides access to advanced functionality. | public int | compareTo(Object partial) Compares this partial with another returning an integer
indicating the order. | public Property | dayOfMonth() Get the day of month property which provides access to advanced functionality. | public Property | dayOfWeek() Get the day of week property which provides access to advanced functionality. | public Property | dayOfYear() Get the day of year property which provides access to advanced functionality. | public boolean | equals(Object partial) Compares this ReadablePartial with another returning true if the chronology,
field types and values are equal. | public Property | era() Get the era property which provides access to advanced functionality. | public static LocalDateTime | fromCalendarFields(Calendar calendar) Constructs a LocalDateTime 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 LocalDateTime.
This is useful if you have been using the Calendar as a local date,
ignoing the zone.
This factory method ignores the type of the calendar and always
creates a LocalDateTime with ISO chronology. | public static LocalDateTime | fromDateFields(Date date) Constructs a LocalDateTime from a java.util.Date
using exactly the same field values avoiding any time zone effects. | public int | get(DateTimeFieldType type) Get the value of one of the fields of a datetime. | public int | getCenturyOfEra() Get the year of era field value. | public Chronology | getChronology() Gets the chronology of the datetime. | public int | getDayOfMonth() Get the day of month field value. | public int | getDayOfWeek() Get the day of week field value. | public int | getDayOfYear() Get the day of year field value. | public int | getEra() Get the era field value. | protected DateTimeField | getField(int index, Chronology chrono) Gets the field for a specific index in the chronology specified. | public int | getHourOfDay() Get the hour of day field value. | protected long | getLocalMillis() Gets the milliseconds of the datetime instant from the Java epoch
of 1970-01-01T00:00:00 (not fixed to any specific time zone). | public int | getMillisOfDay() Get the millis of day field value. | public int | getMillisOfSecond() Get the millis of second field value. | public int | getMinuteOfHour() Get the minute of hour field value. | public int | getMonthOfYear() Get the month of year field value. | public int | getSecondOfMinute() Get the second of minute field value. | public int | getValue(int index) Gets the value of the field at the specifed index.
This method is required to support the ReadablePartial
interface. | public int | getWeekOfWeekyear() Get the week of weekyear field value. | public int | getWeekyear() Get the weekyear field value.
The weekyear is the year that matches with the weekOfWeekyear field.
In the standard ISO8601 week algorithm, the first week of the year
is that in which at least 4 days are in the year. | public int | getYear() Get the year field value. | public int | getYearOfCentury() Get the year of century field value. | public int | getYearOfEra() Get the year of era field value. | public Property | hourOfDay() Get the hour of day field property which provides access to advanced functionality. | public boolean | isSupported(DateTimeFieldType type) Checks if the field type specified is supported by this
local datetime and chronology. | public boolean | isSupported(DurationFieldType type) Checks if the duration type specified is supported by this
local datetime and chronology. | public Property | millisOfDay() Get the millis of day property which provides access to advanced functionality. | public Property | millisOfSecond() Get the millis of second property which provides access to advanced functionality. | public LocalDateTime | minus(ReadableDuration duration) Returns a copy of this datetime with the specified duration taken away. | public LocalDateTime | minus(ReadablePeriod period) Returns a copy of this datetime with the specified period taken away. | public LocalDateTime | minusDays(int days) Returns a copy of this datetime minus the specified number of days. | public LocalDateTime | minusHours(int hours) Returns a copy of this datetime minus the specified number of hours. | public LocalDateTime | minusMillis(int millis) Returns a copy of this datetime minus the specified number of millis. | public LocalDateTime | minusMinutes(int minutes) Returns a copy of this datetime minus the specified number of minutes. | public LocalDateTime | minusMonths(int months) Returns a copy of this datetime minus the specified number of months. | public LocalDateTime | minusSeconds(int seconds) Returns a copy of this datetime minus the specified number of seconds. | public LocalDateTime | minusWeeks(int weeks) Returns a copy of this datetime minus the specified number of weeks. | public LocalDateTime | minusYears(int years) Returns a copy of this datetime minus the specified number of years. | public Property | minuteOfHour() Get the minute of hour field property which provides access to advanced functionality. | public Property | monthOfYear() Get the month of year property which provides access to advanced functionality. | public LocalDateTime | plus(ReadableDuration duration) Returns a copy of this datetime with the specified duration added. | public LocalDateTime | plus(ReadablePeriod period) Returns a copy of this datetime with the specified period added. | public LocalDateTime | plusDays(int days) Returns a copy of this datetime plus the specified number of days. | public LocalDateTime | plusHours(int hours) Returns a copy of this datetime plus the specified number of hours. | public LocalDateTime | plusMillis(int millis) Returns a copy of this datetime plus the specified number of millis. | public LocalDateTime | plusMinutes(int minutes) Returns a copy of this datetime plus the specified number of minutes. | public LocalDateTime | plusMonths(int months) Returns a copy of this datetime plus the specified number of months. | public LocalDateTime | plusSeconds(int seconds) Returns a copy of this datetime plus the specified number of seconds. | public LocalDateTime | plusWeeks(int weeks) Returns a copy of this datetime plus the specified number of weeks. | public LocalDateTime | plusYears(int years) Returns a copy of this datetime plus the specified number of years. | public Property | property(DateTimeFieldType fieldType) Gets the property object for the specified type, which contains many
useful methods. | public Property | secondOfMinute() Get the second of minute field property which provides access to advanced functionality. | public int | size() Gets the number of fields in this partial, which is four. | public DateTime | toDateTime() Converts this object to a DateTime using the default zone. | public DateTime | toDateTime(DateTimeZone zone) Converts this object to a DateTime using the specified zone. | public LocalDate | toLocalDate() Converts this object to a LocalDate with the same date and chronology. | public LocalTime | toLocalTime() Converts this object to a LocalTime with the same time and chronology. | public String | toString() Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSS). | public String | toString(String pattern) Output the date using the specified format pattern. | public String | toString(String pattern, Locale locale) Output the date using the specified format pattern. | public Property | weekOfWeekyear() Get the week of a week based year property which provides access to advanced functionality. | public Property | weekyear() Get the weekyear property which provides access to advanced functionality. | public LocalDateTime | withCenturyOfEra(int centuryOfEra) Returns a copy of this datetime with the century of era field updated. | public LocalDateTime | withDate(int year, int monthOfYear, int dayOfMonth) Returns a copy of this datetime with the specified date,
retaining the time fields. | public LocalDateTime | withDayOfMonth(int dayOfMonth) Returns a copy of this datetime with the day of month field updated. | public LocalDateTime | withDayOfWeek(int dayOfWeek) Returns a copy of this datetime with the day of week field updated. | public LocalDateTime | withDayOfYear(int dayOfYear) Returns a copy of this datetime with the day of year field updated. | public LocalDateTime | withDurationAdded(ReadableDuration durationToAdd, int scalar) Returns a copy of this datetime with the specified duration added. | public LocalDateTime | withEra(int era) Returns a copy of this datetime with the era field updated. | public LocalDateTime | withField(DateTimeFieldType fieldType, int value) Returns a copy of this datetime with the specified field set to a new value. | public LocalDateTime | withFieldAdded(DurationFieldType fieldType, int amount) Returns a copy of this datetime with the value of the specified
field increased. | public LocalDateTime | withFields(ReadablePartial partial) Returns a copy of this datetime with the partial set of fields
replacing those from this instance. | public LocalDateTime | withHourOfDay(int hour) Returns a copy of this datetime with the hour of day field updated. | LocalDateTime | withLocalMillis(long newMillis) Returns a copy of this datetime with different local millis. | public LocalDateTime | withMillisOfDay(int millis) Returns a copy of this datetime with the millis of day field updated. | public LocalDateTime | withMillisOfSecond(int millis) Returns a copy of this datetime with the millis of second field updated. | public LocalDateTime | withMinuteOfHour(int minute) Returns a copy of this datetime with the minute of hour field updated. | public LocalDateTime | withMonthOfYear(int monthOfYear) Returns a copy of this datetime with the month of year field updated. | public LocalDateTime | withPeriodAdded(ReadablePeriod period, int scalar) Returns a copy of this datetime with the specified period added.
If the addition is zero, then this is returned.
This method is typically used to add multiple copies of complex
period instances. | public LocalDateTime | withSecondOfMinute(int second) Returns a copy of this datetime with the second of minute field updated. | public LocalDateTime | withTime(int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) Returns a copy of this datetime with the specified time,
retaining the date fields. | public LocalDateTime | withWeekOfWeekyear(int weekOfWeekyear) Returns a copy of this datetime with the week of weekyear field updated. | public LocalDateTime | withWeekyear(int weekyear) Returns a copy of this datetime with the weekyear field updated. | public LocalDateTime | withYear(int year) Returns a copy of this datetime with the year field updated. | public LocalDateTime | withYearOfCentury(int yearOfCentury) Returns a copy of this datetime with the year of century field updated. | public LocalDateTime | withYearOfEra(int yearOfEra) Returns a copy of this datetime with the year of era field updated. | public Property | year() Get the year property which provides access to advanced functionality. | public Property | yearOfCentury() Get the year of century property which provides access to advanced functionality. | public Property | yearOfEra() Get the year of era property which provides access to advanced functionality. |
LocalDateTime | public LocalDateTime()(Code) | | Constructs an instance set to the current local time evaluated using
ISO chronology in the default zone.
Once the constructor is completed, the zone is no longer used.
|
LocalDateTime | public LocalDateTime(DateTimeZone zone)(Code) | | Constructs an instance set to the current local time evaluated using
ISO chronology in the specified zone.
If the specified time zone is null, the default zone is used.
Once the constructor is completed, the zone is no longer used.
Parameters: zone - the time zone, null means default zone |
LocalDateTime | public LocalDateTime(Chronology chronology)(Code) | | Constructs an instance set to the current local time evaluated using
specified chronology.
If the chronology is null, ISO chronology in the default time zone is used.
Once the constructor is completed, the zone is no longer used.
Parameters: chronology - the chronology, null means ISOChronology in default zone |
LocalDateTime | public LocalDateTime(long instant)(Code) | | Constructs an instance set to the local time defined by the specified
instant evaluated using ISO chronology in the default zone.
Once the constructor is completed, the zone is no longer used.
Parameters: instant - the milliseconds from 1970-01-01T00:00:00Z |
LocalDateTime | public LocalDateTime(long instant, DateTimeZone zone)(Code) | | Constructs an instance set to the local time defined by the specified
instant evaluated using ISO chronology in the specified zone.
If the specified time zone is null, the default zone is used.
Once the constructor is completed, the zone is no longer used.
Parameters: instant - the milliseconds from 1970-01-01T00:00:00Z Parameters: zone - the time zone, null means default zone |
LocalDateTime | public LocalDateTime(long instant, Chronology chronology)(Code) | | Constructs an instance set to the local time defined by the specified
instant evaluated using the specified chronology.
If the chronology is null, ISO chronology in the default zone is used.
Once the constructor is completed, the zone is no longer used.
Parameters: instant - the milliseconds from 1970-01-01T00:00:00Z Parameters: chronology - the chronology, null means ISOChronology in default zone |
LocalDateTime | public LocalDateTime(Object instant)(Code) | | Constructs an instance from an Object that represents a datetime.
If the object contains no chronology, ISOChronology is used.
If the object contains no time zone, the default zone is used.
Once the constructor is completed, the zone is no longer used.
The recognised object types are defined in
org.joda.time.convert.ConverterManager ConverterManager and
include ReadablePartial, ReadableInstant, String, Calendar and Date.
The String formats are described by
ISODateTimeFormat.localDateOptionalTimeParser .
The default String converter ignores the zone and only parses the field values.
Parameters: instant - the datetime object throws: IllegalArgumentException - if the instant is invalid |
LocalDateTime | public LocalDateTime(Object instant, DateTimeZone zone)(Code) | | Constructs an instance from an Object that represents a datetime,
forcing the time zone to that specified.
If the object contains no chronology, ISOChronology is used.
If the specified time zone is null, the default zone is used.
Once the constructor is completed, the zone is no longer used.
The recognised object types are defined in
org.joda.time.convert.ConverterManager ConverterManager and
include ReadablePartial, ReadableInstant, String, Calendar and Date.
The String formats are described by
ISODateTimeFormat.localDateOptionalTimeParser .
The default String converter ignores the zone and only parses the field values.
Parameters: instant - the datetime object Parameters: zone - the time zone throws: IllegalArgumentException - if the instant is invalid |
LocalDateTime | public LocalDateTime(Object instant, Chronology chronology)(Code) | | 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.
Once the constructor is completed, the zone is no longer used.
The recognised object types are defined in
org.joda.time.convert.ConverterManager ConverterManager and
include ReadablePartial, ReadableInstant, String, Calendar and Date.
The String formats are described by
ISODateTimeFormat.localDateOptionalTimeParser .
The default String converter ignores the zone and only parses the field values.
Parameters: instant - the datetime object Parameters: chronology - the chronology throws: IllegalArgumentException - if the instant is invalid |
LocalDateTime | public LocalDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)(Code) | | Constructs an instance set to the specified date and time
using ISOChronology .
Parameters: year - the year Parameters: monthOfYear - the month of the year Parameters: dayOfMonth - the day of the month Parameters: hourOfDay - the hour of the day Parameters: minuteOfHour - the minute of the hour |
LocalDateTime | public LocalDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute)(Code) | | Constructs an instance set to the specified date and time
using ISOChronology .
Parameters: year - the year Parameters: monthOfYear - the month of the year Parameters: dayOfMonth - the day of the month Parameters: hourOfDay - the hour of the day Parameters: minuteOfHour - the minute of the hour Parameters: secondOfMinute - the second of the minute |
LocalDateTime | public LocalDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)(Code) | | Constructs an instance set to the specified date and time
using ISOChronology .
Parameters: year - the year Parameters: monthOfYear - the month of the year Parameters: dayOfMonth - the day of the month Parameters: hourOfDay - the hour of the day Parameters: minuteOfHour - the minute of the hour Parameters: secondOfMinute - the second of the minute Parameters: millisOfSecond - the millisecond of the second |
LocalDateTime | public LocalDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond, Chronology chronology)(Code) | | Constructs an instance set to the specified date and time
using the specified chronology, whose zone is ignored.
If the chronology is null, ISOChronology is used.
Parameters: year - the year Parameters: monthOfYear - the month of the year Parameters: dayOfMonth - the day of the month Parameters: hourOfDay - the hour of the day Parameters: minuteOfHour - the minute of the hour Parameters: secondOfMinute - the second of the minute Parameters: millisOfSecond - the millisecond of the second Parameters: chronology - the chronology, null means ISOChronology in default zone |
centuryOfEra | public Property centuryOfEra()(Code) | | Get the century of era property which provides access to advanced functionality.
the year of era property |
compareTo | public int compareTo(Object partial)(Code) | | Compares this partial with another returning an integer
indicating the order.
The fields are compared in order, from largest to smallest.
The first field that is non-equal is used to determine the result.
The specified object must be a partial instance whose field types
match those of this partial.
NOTE: This implementation violates the Comparable contract.
This method will accept any instance of ReadablePartial as input.
However, it is possible that some implementations of ReadablePartial
exist that do not extend AbstractPartial, and thus will throw a
ClassCastException if compared in the opposite direction.
The cause of this problem is that ReadablePartial doesn't define
the compareTo() method, however we can't change that until v2.0.
Parameters: partial - an object to check against negative if this is less, zero if equal, positive if greater throws: ClassCastException - if the partial is the wrong classor if it has field types that don't match throws: NullPointerException - if the partial is null |
dayOfMonth | public Property dayOfMonth()(Code) | | Get the day of month property which provides access to advanced functionality.
the day of month property |
dayOfWeek | public Property dayOfWeek()(Code) | | Get the day of week property which provides access to advanced functionality.
the day of week property |
dayOfYear | public Property dayOfYear()(Code) | | Get the day of year property which provides access to advanced functionality.
the day of year property |
equals | public boolean equals(Object partial)(Code) | | Compares this ReadablePartial with another returning true if the chronology,
field types and values are equal.
Parameters: partial - an object to check against true if fields and values are equal |
era | public Property era()(Code) | | Get the era property which provides access to advanced functionality.
the era property |
fromCalendarFields | public static LocalDateTime fromCalendarFields(Calendar calendar)(Code) | | Constructs a LocalDateTime 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 LocalDateTime.
This is useful if you have been using the Calendar as a local date,
ignoing the zone.
This factory method ignores the type of the calendar and always
creates a LocalDateTime 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 the created LocalDateTime throws: IllegalArgumentException - if the calendar is null throws: IllegalArgumentException - if the date is invalid for the ISO chronology |
fromDateFields | public static LocalDateTime fromDateFields(Date date)(Code) | | Constructs a LocalDateTime 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 LocalDateTime.
This is useful if you have been using the Date as a local date,
ignoing the zone.
This factory method always creates a LocalDateTime with ISO chronology.
Parameters: date - the Date to extract fields from the created LocalDateTime throws: IllegalArgumentException - if the calendar is null throws: IllegalArgumentException - if the date is invalid for the ISO chronology |
get | public int get(DateTimeFieldType type)(Code) | | Get the value of one of the fields of a datetime.
This method gets the value of the specified field.
For example:
DateTime dt = new DateTime();
int year = dt.get(DateTimeFieldType.year());
Parameters: type - a field type, usually obtained from DateTimeFieldType, not null the value of that field throws: IllegalArgumentException - if the field type is null |
getCenturyOfEra | public int getCenturyOfEra()(Code) | | Get the year of era field value.
the year of era |
getChronology | public Chronology getChronology()(Code) | | Gets the chronology of the datetime.
the Chronology that the datetime is using |
getDayOfYear | public int getDayOfYear()(Code) | | Get the day of year field value.
the day of year |
getEra | public int getEra()(Code) | | Get the era field value.
the era |
getField | protected DateTimeField getField(int index, Chronology chrono)(Code) | | 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 Parameters: chrono - the chronology to use the field |
getHourOfDay | public int getHourOfDay()(Code) | | Get the hour of day field value.
the hour of day |
getLocalMillis | protected long getLocalMillis()(Code) | | Gets the milliseconds of the datetime instant from the Java epoch
of 1970-01-01T00:00:00 (not fixed to any specific time zone).
the number of milliseconds since 1970-01-01T00:00:00 since: 1.5 (previously private) |
getMillisOfDay | public int getMillisOfDay()(Code) | | Get the millis of day field value.
the millis of day |
getMillisOfSecond | public int getMillisOfSecond()(Code) | | Get the millis of second field value.
the millis of second |
getMinuteOfHour | public int getMinuteOfHour()(Code) | | Get the minute of hour field value.
the minute of hour |
getMonthOfYear | public int getMonthOfYear()(Code) | | Get the month of year field value.
the month of year |
getSecondOfMinute | public int getSecondOfMinute()(Code) | | Get the second of minute field value.
the second of minute |
getValue | public int getValue(int index)(Code) | | Gets the value of the field at the specifed index.
This method is required to support the ReadablePartial
interface. The supported fields are Year, MonthOfDay, DayOfMonth and MillisOfDay.
Parameters: index - the index, zero to two the value throws: IndexOutOfBoundsException - if the index is invalid |
getWeekOfWeekyear | public int getWeekOfWeekyear()(Code) | | Get the week of weekyear field value.
the week of a week based year |
getWeekyear | public int getWeekyear()(Code) | | Get the weekyear field value.
The weekyear is the year that matches with the weekOfWeekyear field.
In the standard ISO8601 week algorithm, the first week of the year
is that in which at least 4 days are in the year. As a result of this
definition, day 1 of the first week may be in the previous year.
The weekyear allows you to query the effective year for that day.
the weekyear |
getYear | public int getYear()(Code) | | Get the year field value.
the year |
getYearOfCentury | public int getYearOfCentury()(Code) | | Get the year of century field value.
the year of century |
getYearOfEra | public int getYearOfEra()(Code) | | Get the year of era field value.
the year of era |
hourOfDay | public Property hourOfDay()(Code) | | Get the hour of day field property which provides access to advanced functionality.
the hour of day property |
isSupported | public boolean isSupported(DateTimeFieldType type)(Code) | | Checks if the field type specified is supported by this
local datetime and chronology.
This can be used to avoid exceptions in
LocalDateTime.get(DateTimeFieldType) .
Parameters: type - a field type, usually obtained from DateTimeFieldType true if the field type is supported |
isSupported | public boolean isSupported(DurationFieldType type)(Code) | | Checks if the duration type specified is supported by this
local datetime and chronology.
Parameters: type - a duration type, usually obtained from DurationFieldType true if the field type is supported |
millisOfDay | public Property millisOfDay()(Code) | | Get the millis of day property which provides access to advanced functionality.
the millis of day property |
millisOfSecond | public Property millisOfSecond()(Code) | | Get the millis of second property which provides access to advanced functionality.
the millis of second property |
minus | public LocalDateTime minus(ReadableDuration duration)(Code) | | Returns a copy of this datetime with the specified duration taken away.
If the amount is zero or null, then this is returned.
Parameters: duration - the duration to reduce this instant by a copy of this datetime with the duration taken away throws: ArithmeticException - if the result exceeds the internal capacity |
minus | public LocalDateTime minus(ReadablePeriod period)(Code) | | Returns a copy of this datetime 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
LocalDateTime.minusYears(int) .
Parameters: period - the period to reduce this instant by a copy of this datetime with the period taken away throws: ArithmeticException - if the result exceeds the internal capacity |
minusDays | public LocalDateTime minusDays(int days)(Code) | | Returns a copy of this datetime minus the specified number of days.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime subtracted = dt.minusDays(6);
LocalDateTime subtracted = dt.minus(Period.days(6));
LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.days(), -6);
Parameters: days - the amount of days to subtract, may be negative the new LocalDateTime minus the increased days |
minusHours | public LocalDateTime minusHours(int hours)(Code) | | Returns a copy of this datetime minus the specified number of hours.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime subtracted = dt.minusHours(6);
LocalDateTime subtracted = dt.minus(Period.hours(6));
LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.hours(), -6);
Parameters: hours - the amount of hours to subtract, may be negative the new LocalDateTime minus the increased hours |
minusMillis | public LocalDateTime minusMillis(int millis)(Code) | | Returns a copy of this datetime minus the specified number of millis.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime subtracted = dt.minusMillis(6);
LocalDateTime subtracted = dt.minus(Period.millis(6));
LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.millis(), -6);
Parameters: millis - the amount of millis to subtract, may be negative the new LocalDateTime minus the increased millis |
minusMinutes | public LocalDateTime minusMinutes(int minutes)(Code) | | Returns a copy of this datetime minus the specified number of minutes.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime subtracted = dt.minusMinutes(6);
LocalDateTime subtracted = dt.minus(Period.minutes(6));
LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.minutes(), -6);
Parameters: minutes - the amount of minutes to subtract, may be negative the new LocalDateTime minus the increased minutes |
minusMonths | public LocalDateTime minusMonths(int months)(Code) | | Returns a copy of this datetime minus the specified number of months.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime subtracted = dt.minusMonths(6);
LocalDateTime subtracted = dt.minus(Period.months(6));
LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.months(), -6);
Parameters: months - the amount of months to subtract, may be negative the new LocalDateTime minus the increased months |
minusSeconds | public LocalDateTime minusSeconds(int seconds)(Code) | | Returns a copy of this datetime minus the specified number of seconds.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime subtracted = dt.minusSeconds(6);
LocalDateTime subtracted = dt.minus(Period.seconds(6));
LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.seconds(), -6);
Parameters: seconds - the amount of seconds to subtract, may be negative the new LocalDateTime minus the increased seconds |
minusWeeks | public LocalDateTime minusWeeks(int weeks)(Code) | | Returns a copy of this datetime minus the specified number of weeks.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime subtracted = dt.minusWeeks(6);
LocalDateTime subtracted = dt.minus(Period.weeks(6));
LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.weeks(), -6);
Parameters: weeks - the amount of weeks to subtract, may be negative the new LocalDateTime minus the increased weeks |
minusYears | public LocalDateTime minusYears(int years)(Code) | | Returns a copy of this datetime minus the specified number of years.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime subtracted = dt.minusYears(6);
LocalDateTime subtracted = dt.minus(Period.years(6));
LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.years(), -6);
Parameters: years - the amount of years to subtract, may be negative the new LocalDateTime minus the increased years |
minuteOfHour | public Property minuteOfHour()(Code) | | Get the minute of hour field property which provides access to advanced functionality.
the minute of hour property |
monthOfYear | public Property monthOfYear()(Code) | | Get the month of year property which provides access to advanced functionality.
the month of year property |
plus | public LocalDateTime plus(ReadableDuration duration)(Code) | | Returns a copy of this datetime with the specified duration added.
If the amount is zero or null, then this is returned.
Parameters: duration - the duration to add to this one, null means zero a copy of this datetime with the duration added throws: ArithmeticException - if the result exceeds the internal capacity |
plus | public LocalDateTime plus(ReadablePeriod period)(Code) | | Returns a copy of this datetime 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
LocalDateTime.plusYears(int) .
Parameters: period - the period to add to this one, null means zero a copy of this datetime with the period added throws: ArithmeticException - if the result exceeds the internal capacity |
plusDays | public LocalDateTime plusDays(int days)(Code) | | Returns a copy of this datetime plus the specified number of days.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime added = dt.plusDays(6);
LocalDateTime added = dt.plus(Period.days(6));
LocalDateTime added = dt.withFieldAdded(DurationFieldType.days(), 6);
Parameters: days - the amount of days to add, may be negative the new LocalDateTime plus the increased days |
plusHours | public LocalDateTime plusHours(int hours)(Code) | | Returns a copy of this datetime plus the specified number of hours.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime added = dt.plusHours(6);
LocalDateTime added = dt.plus(Period.hours(6));
LocalDateTime added = dt.withFieldAdded(DurationFieldType.hours(), 6);
Parameters: hours - the amount of hours to add, may be negative the new LocalDateTime plus the increased hours |
plusMillis | public LocalDateTime plusMillis(int millis)(Code) | | Returns a copy of this datetime plus the specified number of millis.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime added = dt.plusMillis(6);
LocalDateTime added = dt.plus(Period.millis(6));
LocalDateTime added = dt.withFieldAdded(DurationFieldType.millis(), 6);
Parameters: millis - the amount of millis to add, may be negative the new LocalDateTime plus the increased millis |
plusMinutes | public LocalDateTime plusMinutes(int minutes)(Code) | | Returns a copy of this datetime plus the specified number of minutes.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime added = dt.plusMinutes(6);
LocalDateTime added = dt.plus(Period.minutes(6));
LocalDateTime added = dt.withFieldAdded(DurationFieldType.minutes(), 6);
Parameters: minutes - the amount of minutes to add, may be negative the new LocalDateTime plus the increased minutes |
plusMonths | public LocalDateTime plusMonths(int months)(Code) | | Returns a copy of this datetime plus the specified number of months.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime added = dt.plusMonths(6);
LocalDateTime added = dt.plus(Period.months(6));
LocalDateTime added = dt.withFieldAdded(DurationFieldType.months(), 6);
Parameters: months - the amount of months to add, may be negative the new LocalDateTime plus the increased months |
plusSeconds | public LocalDateTime plusSeconds(int seconds)(Code) | | Returns a copy of this datetime plus the specified number of seconds.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime added = dt.plusSeconds(6);
LocalDateTime added = dt.plus(Period.seconds(6));
LocalDateTime added = dt.withFieldAdded(DurationFieldType.seconds(), 6);
Parameters: seconds - the amount of seconds to add, may be negative the new LocalDateTime plus the increased seconds |
plusWeeks | public LocalDateTime plusWeeks(int weeks)(Code) | | Returns a copy of this datetime plus the specified number of weeks.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime added = dt.plusWeeks(6);
LocalDateTime added = dt.plus(Period.weeks(6));
LocalDateTime added = dt.withFieldAdded(DurationFieldType.weeks(), 6);
Parameters: weeks - the amount of weeks to add, may be negative the new LocalDateTime plus the increased weeks |
plusYears | public LocalDateTime plusYears(int years)(Code) | | Returns a copy of this datetime plus the specified number of years.
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime added = dt.plusYears(6);
LocalDateTime added = dt.plus(Period.years(6));
LocalDateTime added = dt.withFieldAdded(DurationFieldType.years(), 6);
Parameters: years - the amount of years to add, may be negative the new LocalDateTime plus the increased years |
property | public Property property(DateTimeFieldType fieldType)(Code) | | Gets the property object for the specified type, which contains many
useful methods.
Parameters: fieldType - the field type to get the chronology for the property object throws: IllegalArgumentException - if the field is null or unsupported |
secondOfMinute | public Property secondOfMinute()(Code) | | Get the second of minute field property which provides access to advanced functionality.
the second of minute property |
size | public int size()(Code) | | Gets the number of fields in this partial, which is four.
The supported fields are Year, MonthOfDay, DayOfMonth and MillisOfDay.
the field count, four |
toDateTime | public DateTime toDateTime()(Code) | | Converts this object to a DateTime using the default zone.
This method will throw an exception if the datetime that would be
created does not exist when the time zone is taken into account.
this |
toDateTime | public DateTime toDateTime(DateTimeZone zone)(Code) | | Converts this object to a DateTime using the specified zone.
This method will throw an exception if the datetime that would be
created does not exist when the time zone is taken into account.
Parameters: zone - time zone to apply, or default if null a DateTime using the same millis |
toLocalDate | public LocalDate toLocalDate()(Code) | | Converts this object to a LocalDate with the same date and chronology.
a LocalDate with the same date and chronology |
toLocalTime | public LocalTime toLocalTime()(Code) | | Converts this object to a LocalTime with the same time and chronology.
a LocalTime with the same time and chronology |
toString | public String toString()(Code) | | Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSS).
ISO8601 time formatted string. |
weekOfWeekyear | public Property weekOfWeekyear()(Code) | | Get the week of a week based year property which provides access to advanced functionality.
the week of a week based year property |
weekyear | public Property weekyear()(Code) | | Get the weekyear property which provides access to advanced functionality.
the weekyear property |
withCenturyOfEra | public LocalDateTime withCenturyOfEra(int centuryOfEra)(Code) | | Returns a copy of this datetime with the century of era field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
century of era changed.
Parameters: centuryOfEra - the centurey of era to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withDate | public LocalDateTime withDate(int year, int monthOfYear, int dayOfMonth)(Code) | | Returns a copy of this datetime with the specified date,
retaining the time fields.
If the date is already the date passed in, then this is returned.
To set a single field use the properties, for example:
DateTime set = dt.monthOfYear().setCopy(6);
Parameters: year - the new year value Parameters: monthOfYear - the new monthOfYear value Parameters: dayOfMonth - the new dayOfMonth value a copy of this datetime with a different date throws: IllegalArgumentException - if any value if invalid |
withDayOfMonth | public LocalDateTime withDayOfMonth(int dayOfMonth)(Code) | | Returns a copy of this datetime with the day of month field updated.
LocalDateTime 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 a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withDayOfWeek | public LocalDateTime withDayOfWeek(int dayOfWeek)(Code) | | Returns a copy of this datetime with the day of week field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
day of week changed.
Parameters: dayOfWeek - the day of week to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withDayOfYear | public LocalDateTime withDayOfYear(int dayOfYear)(Code) | | Returns a copy of this datetime with the day of year field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
day of year changed.
Parameters: dayOfYear - the day of year to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withDurationAdded | public LocalDateTime withDurationAdded(ReadableDuration durationToAdd, int scalar)(Code) | | Returns a copy of this datetime with the specified duration added.
If the addition is zero, then this is returned.
Parameters: durationToAdd - the duration to add to this one, null means zero Parameters: scalar - the amount of times to add, such as -1 to subtract once a copy of this datetime with the duration added throws: ArithmeticException - if the result exceeds the internal capacity |
withEra | public LocalDateTime withEra(int era)(Code) | | Returns a copy of this datetime with the era field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
era changed.
Parameters: era - the era to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withField | public LocalDateTime withField(DateTimeFieldType fieldType, int value)(Code) | | Returns a copy of this datetime with the specified field set to a new value.
For example, if the field type is hourOfDay then the hour of day
field would be changed in the returned instance.
If the field type is null, then this is returned.
These three lines are equivalent:
LocalDateTime updated = dt.withField(DateTimeFieldType.dayOfMonth(), 6);
LocalDateTime updated = dt.dayOfMonth().setCopy(6);
LocalDateTime updated = dt.property(DateTimeFieldType.dayOfMonth()).setCopy(6);
Parameters: fieldType - the field type to set, not null Parameters: value - the value to set a copy of this datetime with the field set throws: IllegalArgumentException - if the value is null or invalid |
withFieldAdded | public LocalDateTime withFieldAdded(DurationFieldType fieldType, int amount)(Code) | | Returns a copy of this datetime with the value of the specified
field increased.
If the addition is zero or the field is null, then this is returned.
These three lines are equivalent:
LocalDateTime added = dt.withFieldAdded(DurationFieldType.years(), 6);
LocalDateTime added = dt.plusYears(6);
LocalDateTime added = dt.plus(Period.years(6));
Parameters: fieldType - the field type to add to, not null Parameters: amount - the amount to add a copy of this datetime with the field updated throws: IllegalArgumentException - if the value is null or invalid throws: ArithmeticException - if the result exceeds the internal capacity |
withFields | public LocalDateTime withFields(ReadablePartial partial)(Code) | | Returns a copy of this datetime with the partial set of fields
replacing those from this instance.
For example, if the partial is a TimeOfDay then the time fields
would be changed in the returned instance.
If the partial is null, then this is returned.
Parameters: partial - the partial set of fields to apply to this datetime, null ignored a copy of this datetime with a different set of fields throws: IllegalArgumentException - if any value is invalid |
withHourOfDay | public LocalDateTime withHourOfDay(int hour)(Code) | | Returns a copy of this datetime with the hour of day field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
hour of day changed.
Parameters: hour - the hour of day to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withLocalMillis | LocalDateTime withLocalMillis(long newMillis)(Code) | | Returns a copy of this datetime with different local millis.
The returned object will be a new instance of the same type.
Only the millis will change, the chronology is kept.
The returned object will be either be a new instance or this .
Parameters: newMillis - the new millis, from 1970-01-01T00:00:00 a copy of this datetime with different millis |
withMillisOfDay | public LocalDateTime withMillisOfDay(int millis)(Code) | | Returns a copy of this datetime with the millis of day field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
millis of day changed.
Parameters: millis - the millis of day to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withMillisOfSecond | public LocalDateTime withMillisOfSecond(int millis)(Code) | | Returns a copy of this datetime with the millis of second field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
millis of second changed.
Parameters: millis - the millis of second to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withMinuteOfHour | public LocalDateTime withMinuteOfHour(int minute)(Code) | | Returns a copy of this datetime with the minute of hour field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
minute of hour changed.
Parameters: minute - the minute of hour to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withMonthOfYear | public LocalDateTime withMonthOfYear(int monthOfYear)(Code) | | Returns a copy of this datetime with the month of year field updated.
LocalDateTime 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 a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withPeriodAdded | public LocalDateTime withPeriodAdded(ReadablePeriod period, int scalar)(Code) | | Returns a copy of this datetime with the specified period added.
If the addition is zero, then this is returned.
This method is typically used to add multiple copies of complex
period instances. Adding one field is best achieved using methods
like
LocalDateTime.withFieldAdded(DurationFieldType,int) or
LocalDateTime.plusYears(int) .
Parameters: period - the period to add to this one, null means zero Parameters: scalar - the amount of times to add, such as -1 to subtract once a copy of this datetime with the period added throws: ArithmeticException - if the result exceeds the internal capacity |
withSecondOfMinute | public LocalDateTime withSecondOfMinute(int second)(Code) | | Returns a copy of this datetime with the second of minute field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
second of minute changed.
Parameters: second - the second of minute to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withTime | public LocalDateTime withTime(int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond)(Code) | | Returns a copy of this datetime with the specified time,
retaining the date fields.
If the time is already the time passed in, then this is returned.
To set a single field use the properties, for example:
LocalDateTime set = dt.hourOfDay().setCopy(6);
Parameters: hourOfDay - the hour of the day Parameters: minuteOfHour - the minute of the hour Parameters: secondOfMinute - the second of the minute Parameters: millisOfSecond - the millisecond of the second a copy of this datetime with a different time throws: IllegalArgumentException - if any value if invalid |
withWeekOfWeekyear | public LocalDateTime withWeekOfWeekyear(int weekOfWeekyear)(Code) | | Returns a copy of this datetime with the week of weekyear field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
week of weekyear changed.
Parameters: weekOfWeekyear - the week of weekyear to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withWeekyear | public LocalDateTime withWeekyear(int weekyear)(Code) | | Returns a copy of this datetime with the weekyear field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
weekyear changed.
Parameters: weekyear - the weekyear to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withYear | public LocalDateTime withYear(int year)(Code) | | Returns a copy of this datetime with the year field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
year changed.
Parameters: year - the year to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withYearOfCentury | public LocalDateTime withYearOfCentury(int yearOfCentury)(Code) | | Returns a copy of this datetime with the year of century field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
year of century changed.
Parameters: yearOfCentury - the year of century to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
withYearOfEra | public LocalDateTime withYearOfEra(int yearOfEra)(Code) | | Returns a copy of this datetime with the year of era field updated.
LocalDateTime is immutable, so there are no set methods.
Instead, this method returns a new instance with the value of
year of era changed.
Parameters: yearOfEra - the year of era to set a copy of this object with the field set throws: IllegalArgumentException - if the value is invalid |
year | public Property year()(Code) | | Get the year property which provides access to advanced functionality.
the year property |
yearOfCentury | public Property yearOfCentury()(Code) | | Get the year of century property which provides access to advanced functionality.
the year of era property |
yearOfEra | public Property yearOfEra()(Code) | | Get the year of era property which provides access to advanced functionality.
the year of era property |
Methods inherited from org.joda.time.base.BaseLocal | abstract protected long getLocalMillis()(Code)(Java Doc)
|
|
|