public final class

SkipDateTimeField

extends DelegatedDateTimeField
java.lang.Object
   ↳ org.joda.time.DateTimeField
     ↳ org.joda.time.field.DelegatedDateTimeField
       ↳ org.joda.time.field.SkipDateTimeField

Class Overview

Wraps another field such that a certain value is skipped.

This is most useful for years where you want to skip zero, so the sequence runs ...,2,1,-1,-2,...

SkipDateTimeField is thread-safe and immutable.

Summary

Public Constructors
SkipDateTimeField(Chronology chronology, DateTimeField field)
Constructor that skips zero.
SkipDateTimeField(Chronology chronology, DateTimeField field, int skip)
Constructor.
Public Methods
int get(long millis)
Get the value of this field from the milliseconds.
int getMinimumValue()
Get the minimum allowable value for this field.
long set(long millis, int value)
Sets a value in the milliseconds supplied.
[Expand]
Inherited Methods
From class org.joda.time.field.DelegatedDateTimeField
From class org.joda.time.DateTimeField
From class java.lang.Object

Public Constructors

public SkipDateTimeField (Chronology chronology, DateTimeField field)

Constructor that skips zero.

Parameters
chronology the chronoogy to use
field the field to skip zero on

public SkipDateTimeField (Chronology chronology, DateTimeField field, int skip)

Constructor.

Parameters
chronology the chronoogy to use
field the field to skip zero on
skip the value to skip

Public Methods

public int get (long millis)

Get the value of this field from the milliseconds.

Parameters
millis the milliseconds from 1970-01-01T00:00:00Z to query
Returns
  • the value of the field, in the units of the field

public int getMinimumValue ()

Get the minimum allowable value for this field.

Returns
  • the minimum valid value for this field, in the units of the field

public long set (long millis, int value)

Sets a value in the milliseconds supplied.

The value of this field will be set. If the value is invalid, an exception if thrown.

If setting this field would make other fields invalid, then those fields may be changed. For example if the current date is the 31st January, and the month is set to February, the day would be invalid. Instead, the day would be changed to the closest value - the 28th/29th February as appropriate.

Parameters
millis the milliseconds from 1970-01-01T00:00:00Z to set in
value the value to set, in the units of the field
Returns
  • the updated milliseconds