public abstract class

PreciseDurationDateTimeField

extends BaseDateTimeField
java.lang.Object
   ↳ org.joda.time.DateTimeField
     ↳ org.joda.time.field.BaseDateTimeField
       ↳ org.joda.time.field.PreciseDurationDateTimeField
Known Direct Subclasses

Class Overview

Precise datetime field, which has a precise unit duration field.

PreciseDurationDateTimeField is thread-safe and immutable, and its subclasses must be as well.

Summary

Public Constructors
PreciseDurationDateTimeField(DateTimeFieldType type, DurationField unit)
Constructor.
Public Methods
DurationField getDurationField()
Returns the duration per unit value of this field.
int getMinimumValue()
Get the minimum value for the field.
final long getUnitMillis()
boolean isLenient()
Returns false by default.
long remainder(long instant)
This method assumes that this field is properly rounded on 1970-01-01T00:00:00.
long roundCeiling(long instant)
This method assumes that this field is properly rounded on 1970-01-01T00:00:00.
long roundFloor(long instant)
This method assumes that this field is properly rounded on 1970-01-01T00:00:00.
long set(long instant, int value)
Set the specified amount of units to the specified time instant.
Protected Methods
int getMaximumValueForSet(long instant, int value)
Called by the set method to get the maximum allowed value.
[Expand]
Inherited Methods
From class org.joda.time.field.BaseDateTimeField
From class org.joda.time.DateTimeField
From class java.lang.Object

Public Constructors

public PreciseDurationDateTimeField (DateTimeFieldType type, DurationField unit)

Constructor.

Parameters
type the field type
unit precise unit duration, like "days()".
Throws
IllegalArgumentException if duration field is imprecise
IllegalArgumentException if unit milliseconds is less than one

Public Methods

public DurationField getDurationField ()

Returns the duration per unit value of this field. For example, if this field represents "minute of hour", then the duration field is minutes.

Returns
  • the duration of this field, or UnsupportedDurationField if field has no duration

public int getMinimumValue ()

Get the minimum value for the field.

Returns
  • the minimum value

public final long getUnitMillis ()

public boolean isLenient ()

Returns false by default.

Returns
  • true if this field is lenient

public long remainder (long instant)

This method assumes that this field is properly rounded on 1970-01-01T00:00:00. If the rounding alignment differs, override this method as follows:

 return super.remainder(instant + ALIGNMENT_MILLIS);
 

Parameters
instant the milliseconds from 1970-01-01T00:00:00Z to get the remainder
Returns
  • remainder duration, in milliseconds

public long roundCeiling (long instant)

This method assumes that this field is properly rounded on 1970-01-01T00:00:00. If the rounding alignment differs, override this method as follows:

 return super.roundCeiling(instant + ALIGNMENT_MILLIS) - ALIGNMENT_MILLIS;
 

Parameters
instant the milliseconds from 1970-01-01T00:00:00Z to round
Returns
  • rounded milliseconds

public long roundFloor (long instant)

This method assumes that this field is properly rounded on 1970-01-01T00:00:00. If the rounding alignment differs, override this method as follows:

 return super.roundFloor(instant + ALIGNMENT_MILLIS) - ALIGNMENT_MILLIS;
 

Parameters
instant the milliseconds from 1970-01-01T00:00:00Z to round
Returns
  • rounded milliseconds

public long set (long instant, int value)

Set the specified amount of units to the specified time instant.

Parameters
instant the milliseconds from 1970-01-01T00:00:00Z to set in
value value of units to set.
Returns
  • the updated time instant.
Throws
IllegalArgumentException if value is too large or too small.

Protected Methods

protected int getMaximumValueForSet (long instant, int value)

Called by the set method to get the maximum allowed value. By default, returns getMaximumValue(instant). Override to provide a faster implementation.