|
|||||||||
| Home >> All >> org >> joda >> [ time overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.joda.time
Class Partial

java.lang.Objectorg.joda.time.base.AbstractPartial
org.joda.time.Partial
- All Implemented Interfaces:
- java.lang.Comparable, ReadablePartial, java.io.Serializable
- public final class Partial
- extends org.joda.time.base.AbstractPartial
- implements ReadablePartial, java.io.Serializable
- extends org.joda.time.base.AbstractPartial
Partial is an immutable partial datetime supporting any set of datetime fields.
A Partial instance can be used to hold any combination of fields. The instance does not contain a time zone, so any datetime is local.
A Partial can be matched against an instant using isMatch(ReadableInstant) 55 .
This method compares each field on this partial with those of the instant
and determines if the partial matches the instant.
Given this definition, an empty Partial instance represents any datetime
and always matches.
Calculations on Partial are performed using a Chronology. This chronology is set to be in the UTC time zone for all calculations.
Each individual field can be queried in two ways:
get(DateTimeFieldType.monthOfYear())property(DateTimeFieldType.monthOfYear()).get()
- numeric value -
monthOfYear().get() - text value -
monthOfYear().getAsText() - short text value -
monthOfYear().getAsShortText() - maximum/minimum values -
monthOfYear().getMaximumValue() - add/subtract -
monthOfYear().addToCopy() - set -
monthOfYear().setCopy()
Partial is thread-safe and immutable, provided that the Chronology is as well. All standard Chronology classes supplied are thread-safe and immutable.
- Since:
- 1.1
| Nested Class Summary | |
static class |
Partial.Property
The property class for YearMonthDay. |
| Field Summary | |
private Chronology |
iChronology
The chronology in use. |
private org.joda.time.format.DateTimeFormatter[] |
iFormatter
The formatter to use, [0] may miss some fields, [1] doesn't miss any fields. |
private DateTimeFieldType[] |
iTypes
The set of field types. |
private int[] |
iValues
The values of each field in this partial. |
private static long |
serialVersionUID
Serialization version |
| Constructor Summary | |
|
Partial()
Constructs a Partial with no fields or values, which can be considered to represent any date. |
|
Partial(Chronology chrono)
Constructs a Partial with no fields or values, which can be considered to represent any date. |
(package private) |
Partial(Chronology chronology,
DateTimeFieldType[] types,
int[] values)
Constructs a Partial with the specified chronology, fields and values. |
|
Partial(DateTimeFieldType[] types,
int[] values)
Constructs a Partial with the specified fields and values. |
|
Partial(DateTimeFieldType[] types,
int[] values,
Chronology chronology)
Constructs a Partial with the specified fields and values. |
|
Partial(DateTimeFieldType type,
int value)
Constructs a Partial with the specified field and value. |
|
Partial(DateTimeFieldType type,
int value,
Chronology chronology)
Constructs a Partial with the specified field and value. |
(package private) |
Partial(Partial partial,
int[] values)
Constructs a Partial with the specified values. |
|
Partial(ReadablePartial partial)
Constructs a Partial by copying all the fields and types from another partial. |
| Method Summary | |
Chronology |
getChronology()
Gets the chronology of the partial which is never null. |
protected DateTimeField |
getField(int index,
Chronology chrono)
Gets the field for a specific index in the chronology specified. |
DateTimeFieldType |
getFieldType(int index)
Gets the field type at the specified index. |
DateTimeFieldType[] |
getFieldTypes()
Gets an array of the field type of each of the fields that this partial supports. |
org.joda.time.format.DateTimeFormatter |
getFormatter()
Gets a formatter suitable for the fields in this partial. |
int |
getValue(int index)
Gets the value of the field at the specifed index. |
int[] |
getValues()
Gets an array of the value of each of the fields that this partial supports. |
boolean |
isMatch(ReadableInstant instant)
Does this partial match the specified instant. |
Partial |
minus(ReadablePeriod period)
Gets a copy of this instance with the specified period take away. |
Partial |
plus(ReadablePeriod period)
Gets a copy of this instance with the specified period added. |
Partial.Property |
property(DateTimeFieldType type)
Gets the property object for the specified type, which contains many useful methods for getting and manipulating the partial. |
int |
size()
Gets the number of fields in this partial. |
java.lang.String |
toString()
Output the date in an appropriate ISO8601 format. |
java.lang.String |
toString(java.lang.String pattern)
Output the date using the specified format pattern. |
java.lang.String |
toString(java.lang.String pattern,
java.util.Locale locale)
Output the date using the specified format pattern. |
java.lang.String |
toStringList()
Gets a string version of the partial that lists all the fields. |
Partial |
with(DateTimeFieldType fieldType,
int value)
Gets a copy of this date with the specified field set to a new value. |
Partial |
withChronologyRetainFields(Chronology newChronology)
Creates a new Partial instance with the specified chronology. |
Partial |
withField(DateTimeFieldType fieldType,
int value)
Gets a copy of this Partial with the specified field set to a new value. |
Partial |
withFieldAdded(DurationFieldType fieldType,
int amount)
Gets a copy of this Partial with the value of the specified field increased. |
Partial |
withFieldAddWrapped(DurationFieldType fieldType,
int amount)
Gets a copy of this Partial with the value of the specified field increased. |
Partial |
without(DateTimeFieldType fieldType)
Gets a copy of this date with the specified field removed. |
Partial |
withPeriodAdded(ReadablePeriod period,
int scalar)
Gets a copy of this Partial with the specified period added. |
| Methods inherited from class org.joda.time.base.AbstractPartial |
compareTo, equals, get, getField, getFields, hashCode, indexOf, indexOf, indexOfSupported, indexOfSupported, isAfter, isBefore, isEqual, isSupported, toDateTime, toString |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.joda.time.ReadablePartial |
equals, get, getField, hashCode, isSupported, toDateTime |
| Field Detail |
serialVersionUID
private static final long serialVersionUID
- Serialization version
- See Also:
- Constant Field Values
iChronology
private final Chronology iChronology
- The chronology in use.
iTypes
private final DateTimeFieldType[] iTypes
- The set of field types.
iValues
private final int[] iValues
- The values of each field in this partial.
iFormatter
private transient org.joda.time.format.DateTimeFormatter[] iFormatter
- The formatter to use, [0] may miss some fields, [1] doesn't miss any fields.
| Constructor Detail |
Partial
public Partial()
- Constructs a Partial with no fields or values, which can be considered
to represent any date.
This is most useful when constructing partials, for example:
Partial p = new Partial() .with(DateTimeFieldType.dayOfWeek(), 5) .with(DateTimeFieldType.hourOfDay(), 12) .with(DateTimeFieldType.minuteOfHour(), 20);Note that, although this is a clean way to write code, it is fairly inefficient internally.The constructor uses the default ISO chronology.
Partial
public Partial(Chronology chrono)
- Constructs a Partial with no fields or values, which can be considered
to represent any date.
This is most useful when constructing partials, for example:
Partial p = new Partial(chrono) .with(DateTimeFieldType.dayOfWeek(), 5) .with(DateTimeFieldType.hourOfDay(), 12) .with(DateTimeFieldType.minuteOfHour(), 20);Note that, although this is a clean way to write code, it is fairly inefficient internally.
Partial
public Partial(DateTimeFieldType type, int value)
- Constructs a Partial with the specified field and value.
The constructor uses the default ISO chronology.
Partial
public Partial(DateTimeFieldType type, int value, Chronology chronology)
- Constructs a Partial with the specified field and value.
The constructor uses the specified chronology.
Partial
public Partial(DateTimeFieldType[] types, int[] values)
- Constructs a Partial with the specified fields and values.
The fields must be specified in the order largest to smallest.
The constructor uses the specified chronology.
Partial
public Partial(DateTimeFieldType[] types, int[] values, Chronology chronology)
- Constructs a Partial with the specified fields and values.
The fields must be specified in the order largest to smallest.
The constructor uses the specified chronology.
Partial
public Partial(ReadablePartial partial)
- Constructs a Partial by copying all the fields and types from
another partial.
This is most useful when copying from a YearMonthDay or TimeOfDay.
Partial
Partial(Partial partial, int[] values)
- Constructs a Partial with the specified values.
This constructor assigns and performs no validation.
Partial
Partial(Chronology chronology, DateTimeFieldType[] types, int[] values)
- Constructs a Partial with the specified chronology, fields and values.
This constructor assigns and performs no validation.
| Method Detail |
size
public int size()
- Gets the number of fields in this partial.
- Specified by:
sizein interfaceReadablePartial
getChronology
public Chronology getChronology()
- Gets the chronology of the partial which is never null.
The Chronology is the calculation engine behind the partial and provides conversion and validation of the fields in a particular calendar system.
- Specified by:
getChronologyin interfaceReadablePartial
getField
protected DateTimeField getField(int index, Chronology chrono)
- Gets the field for a specific index in the chronology specified.
getFieldType
public DateTimeFieldType getFieldType(int index)
- Gets the field type at the specified index.
- Specified by:
getFieldTypein interfaceReadablePartial
getFieldTypes
public DateTimeFieldType[] getFieldTypes()
- Gets an array of the field type of each of the fields that
this partial supports.
The fields are returned largest to smallest.
getValue
public int getValue(int index)
- Gets the value of the field at the specifed index.
- Specified by:
getValuein interfaceReadablePartial
getValues
public int[] getValues()
- Gets an array of the value of each of the fields that
this partial supports.
The fields are returned largest to smallest. Each value corresponds to the same array index as
getFieldTypes()
withChronologyRetainFields
public Partial withChronologyRetainFields(Chronology newChronology)
- Creates a new Partial instance with the specified chronology.
This instance is immutable and unaffected by this method call.
This method retains the values of the fields, thus the result will typically refer to a different instant.
The time zone of the specified chronology is ignored, as Partial operates without a time zone.
with
public Partial with(DateTimeFieldType fieldType, int value)
- Gets a copy of this date with the specified field set to a new value.
If this partial did not previously support the field, the new one will. Contrast this behaviour with
withField(DateTimeFieldType, int)55 .For example, if the field type is
dayOfMonththen the day would be changed/added in the returned instance.
without
public Partial without(DateTimeFieldType fieldType)
- Gets a copy of this date with the specified field removed.
If this partial did not previously support the field, no error occurs.
withField
public Partial withField(DateTimeFieldType fieldType, int value)
- Gets a copy of this Partial with the specified field set to a new value.
If this partial does not support the field, an exception is thrown. Contrast this behaviour with
with(DateTimeFieldType, int)55 .For example, if the field type is
dayOfMonththen the day would be changed in the returned instance if supported.
withFieldAdded
public Partial withFieldAdded(DurationFieldType fieldType, int amount)
- Gets a copy of this Partial with the value of the specified field increased.
If this partial does not support the field, an exception is thrown.
If the addition is zero, then
thisis returned. The addition will overflow into larger fields (eg. minute to hour). However, it will not wrap around if the top maximum is reached.
withFieldAddWrapped
public Partial withFieldAddWrapped(DurationFieldType fieldType, int amount)
- Gets a copy of this Partial with the value of the specified field increased.
If this partial does not support the field, an exception is thrown.
If the addition is zero, then
thisis returned. The addition will overflow into larger fields (eg. minute to hour). If the maximum is reached, the addition will wra.
withPeriodAdded
public Partial withPeriodAdded(ReadablePeriod period, int scalar)
- Gets a copy of this Partial with the specified period added.
If the addition is zero, then
thisis returned. Fields in the period that aren't present in the partial are ignored.This method is typically used to add multiple copies of complex period instances. Adding one field is best achieved using the method
withFieldAdded(DurationFieldType, int)55 .
plus
public Partial plus(ReadablePeriod period)
- Gets a copy of this instance with the specified period added.
If the amount is zero or null, then
thisis returned.
minus
public Partial minus(ReadablePeriod period)
- Gets a copy of this instance with the specified period take away.
If the amount is zero or null, then
thisis returned.
property
public Partial.Property property(DateTimeFieldType type)
- Gets the property object for the specified type, which contains
many useful methods for getting and manipulating the partial.
See also
ReadablePartial.get(DateTimeFieldType)55 .
isMatch
public boolean isMatch(ReadableInstant instant)
- Does this partial match the specified instant.
A match occurs when all the fields of this partial are the same as the corresponding fields on the specified instant.
getFormatter
public org.joda.time.format.DateTimeFormatter getFormatter()
- Gets a formatter suitable for the fields in this partial.
If there is no appropriate ISO format, null is returned. This method may return a formatter that does not display all the fields of the partial. This might occur when you have overlapping fields, such as dayOfWeek and dayOfMonth.
toString
public java.lang.String toString()
- Output the date in an appropriate ISO8601 format.
This method will output the partial in one of two ways. If
getFormatter()55 If there is no appropriate ISO format a dump of the fields is output viatoStringList()55 . An appropr- Specified by:
toStringin interfaceReadablePartial
toStringList
public java.lang.String toStringList()
- Gets a string version of the partial that lists all the fields.
This method exists to provide a better debugging toString than the standard toString. This method lists all the fields and their values in a style similar to the collections framework.
toString
public java.lang.String toString(java.lang.String pattern)
- Output the date using the specified format pattern.
Unsupported fields will appear as special unicode characters.
toString
public java.lang.String toString(java.lang.String pattern, java.util.Locale locale)
- Output the date using the specified format pattern.
Unsupported fields will appear as special unicode characters.
|
|||||||||
| Home >> All >> org >> joda >> [ time overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC