public class

MockPartial

extends Object
implements ReadablePartial
java.lang.Object
   ↳ org.joda.time.MockPartial

Class Overview

A basic mock testing class for a PartialInstant that doesn't extend AbstractPartialInstant.

Summary

Fields
public static final ReadablePartial EMPTY_INSTANCE
Public Constructors
MockPartial()
Public Methods
int get(DateTimeFieldType field)
Gets the value of one of the fields.
Chronology getChronology()
Gets the chronology of the partial which is never null.
DateTimeField getField(int index)
Gets the field at the specified index.
DateTimeFieldType getFieldType(int index)
Gets the field type at the specified index.
DateTimeField[] getFields()
int getValue(int index)
Gets the value at the specified index.
int[] getValues()
boolean isSupported(DateTimeFieldType field)
Checks whether the field type specified is supported by this partial.
int size()
Gets the number of fields that this partial supports.
DateTime toDateTime(ReadableInstant base)
Converts this partial to a full datetime by resolving it against another datetime.
DateTime toDateTime(DateTimeZone zone)
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.joda.time.ReadablePartial

Fields

public static final ReadablePartial EMPTY_INSTANCE

Public Constructors

public MockPartial ()

Public Methods

public int get (DateTimeFieldType field)

Gets the value of one of the fields.

The field type specified must be one of those that is supported by the partial.

Parameters
field a DateTimeFieldType instance that is supported by this partial
Returns
  • the value of that field

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.

Returns
  • the chronology, never null

public DateTimeField getField (int index)

Gets the field at the specified index.

Parameters
index the index to retrieve
Returns
  • the field at the specified index

public DateTimeFieldType getFieldType (int index)

Gets the field type at the specified index.

Parameters
index the index to retrieve
Returns
  • the field at the specified index

public DateTimeField[] getFields ()

public int getValue (int index)

Gets the value at the specified index.

Parameters
index the index to retrieve
Returns
  • the value of the field at the specified index

public int[] getValues ()

public boolean isSupported (DateTimeFieldType field)

Checks whether the field type specified is supported by this partial.

Parameters
field the field to check, may be null which returns false
Returns
  • true if the field is supported

public int size ()

Gets the number of fields that this partial supports.

Returns
  • the number of fields supported

public DateTime toDateTime (ReadableInstant base)

Converts this partial to a full datetime by resolving it against another datetime.

This method takes the specified datetime and sets the fields from this instant on top. The chronology from the base instant is used.

For example, if this partial represents a time, then the result of this method will be the datetime from the specified base instant plus the time from this partial.

Parameters
base the instant that provides the missing fields, null means now
Returns
  • the combined datetime

public DateTime toDateTime (DateTimeZone zone)