|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DateTimeField
A field of date/time.
A date, as expressed by LocalDateTime
, is broken down into a number of fields,
such as year, month, day-of-month, hour, minute and second.
Implementations of this interface represent those fields.
The fields include their own calculations which are specific to one calendar system.
Method Summary | |
---|---|
int |
compare(CalendricalObject calendrical1,
CalendricalObject calendrical2)
Compares the value of this field in two calendricals. |
long |
get(LocalDate date)
Gets the value of the associated field. |
long |
get(LocalDateTime dateTime)
Gets the value of the associated field. |
long |
get(LocalTime time)
Gets the value of the associated field. |
PeriodUnit |
getBaseUnit()
Gets the unit that the field is measured in. |
java.lang.String |
getName()
Gets a descriptive name for the field. |
PeriodUnit |
getRangeUnit()
Gets the range that the field is bound by. |
long |
getValueFrom(CalendricalObject calendrical)
Gets the value of the field from the specified calendrical. |
DateTimeValueRange |
getValueRange()
Gets the range of valid values for the field. |
DateTimeValueRange |
range(LocalDate date)
Gets the range of valid values for the associated field. |
DateTimeValueRange |
range(LocalDateTime dateTime)
Gets the range of valid values for the associated field. |
DateTimeValueRange |
range(LocalTime time)
Gets the range of valid values for the associated field. |
boolean |
resolve(DateTimeBuilder builder,
long value)
Resolves the date/time information in the builder |
LocalDate |
roll(LocalDate date,
long roll)
Rolls the value of the associated field in the result. |
LocalDateTime |
roll(LocalDateTime dateTime,
long roll)
Rolls the value of the associated field in the result. |
LocalTime |
roll(LocalTime time,
long roll)
Rolls the value of the associated field in the result. |
LocalDate |
set(LocalDate date,
long newValue)
Sets the value of the associated field in the result. |
LocalDateTime |
set(LocalDateTime dateTime,
long newValue)
Sets the value of the associated field in the result. |
LocalTime |
set(LocalTime time,
long newValue)
Sets the value of the associated field in the result. |
Methods inherited from interface java.util.Comparator |
---|
equals |
Method Detail |
---|
java.lang.String getName()
The should be of the format 'BaseOfRange', such as 'MonthOfYear', unless the field is unbounded, such as 'Year' or 'Era', when only the base unit is mentioned.
DateTimeValueRange getValueRange()
All fields can be expressed as a long
integer.
This method returns an object that describes the valid range for that value.
Note that the result only describes the minimum and maximum valid values and it is important not to read too much into them. For example, there could be values within the range that are invalid for the field.
PeriodUnit getBaseUnit()
The unit of the field is the period that varies within the range.
For example, in the field 'MonthOfYear', the unit is 'Months'.
See also getRangeUnit()
.
PeriodUnit getRangeUnit()
The range of the field is the period that the field varies within.
For example, in the field 'MonthOfYear', the range is 'Years'.
See also getBaseUnit()
.
The range is never null. For example, the 'Year' field is shorthand for 'YearOfForever'. It therefore has a unit of 'Years' and a range of 'Forever'.
long getValueFrom(CalendricalObject calendrical)
The value will be within the valid range for the field.
calendrical
- the calendrical object, not null
CalendricalException
- if unable to get the field
CalendricalException
- if the field value is invalidint compare(CalendricalObject calendrical1, CalendricalObject calendrical2)
All fields implement Comparator
on CalendricalObject
.
This allows a list of calendricals to be compared using the value of a field.
For example, you could sort a list of arbitrary calendricals by the value of
the month-of-year field - Collections.sort(list, MONTH_OF_YEAR)
compare
in interface java.util.Comparator<CalendricalObject>
calendrical1
- the first calendrical to compare, not nullcalendrical2
- the second calendrical to compare, not null
CalendricalException
- if unable to obtain the value for this fieldDateTimeValueRange range(LocalDate date)
All fields can be expressed as a long
integer.
This method returns an object that describes the valid range for that value.
The date-time object is used to provide context to refine the valid value range.
date
- the context date object, not null
DateTimeValueRange range(LocalTime time)
All fields can be expressed as a long
integer.
This method returns an object that describes the valid range for that value.
The time object is used to provide context to refine the valid value range.
time
- the context time object, not null
DateTimeValueRange range(LocalDateTime dateTime)
All fields can be expressed as a long
integer.
This method returns an object that describes the valid range for that value.
The date-time object is used to provide context to refine the valid value range.
dateTime
- the context date-time object, not null
long get(LocalDate date)
The value of the associated field is expressed as a long
integer
and is extracted from the specified date-time object.
date
- the date object to query, not null
long get(LocalTime time)
The value of the associated field is expressed as a long
integer
and is extracted from the specified date-time object.
time
- the time object to query, not null
long get(LocalDateTime dateTime)
The value of the associated field is expressed as a long
integer
and is extracted from the specified date-time object.
dateTime
- the date-time object to query, not null
LocalDate set(LocalDate date, long newValue)
The new value of the associated field is expressed as a long
integer.
The result will be adjusted to set the value of the associated field.
date
- the date-time object to adjust, not nullnewValue
- the new value of the field
CalendricalException
- if the value is invalidLocalTime set(LocalTime time, long newValue)
The new value of the associated field is expressed as a long
integer.
The result will be adjusted to set the value of the associated field.
time
- the date-time object to adjust, not nullnewValue
- the new value of the field
CalendricalException
- if the value is invalidLocalDateTime set(LocalDateTime dateTime, long newValue)
The new value of the associated field is expressed as a long
integer.
The result will be adjusted to set the value of the associated field.
dateTime
- the date-time object to adjust, not nullnewValue
- the new value of the field
CalendricalException
- if the value is invalidLocalDate roll(LocalDate date, long roll)
The result will have the associated field rolled by the amount specified.
date
- the date object to adjust, not nullroll
- the amount to roll by
LocalTime roll(LocalTime time, long roll)
The result will have the associated field rolled by the amount specified.
time
- the time object to adjust, not nullroll
- the amount to roll by
LocalDateTime roll(LocalDateTime dateTime, long roll)
The result will have the associated field rolled by the amount specified.
dateTime
- the date-time object to adjust, not nullroll
- the amount to roll by
boolean resolve(DateTimeBuilder builder, long value)
This method is invoked during the resolve of the builder.
Implementations should combine the associated field with others to form
objects like LocalDate
, LocalTime
and LocalDateTime
builder
- the builder to resolve, not nullvalue
- the value of the associated field
CalendricalException
- if unable to resolve
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |