Joda Time API

org.joda.time.format
Class DateTimeParserBucket

java.lang.Object
  |
  +--org.joda.time.format.DateTimeParserBucket

public class DateTimeParserBucket
extends java.lang.Object

Allows fields to be saved in any order, but physically set in a consistent order.

Author:
Brian S O'Neill

Constructor Summary
DateTimeParserBucket(long millis)
           
 
Method Summary
 long computeMillis()
          Computes the parsed datetime by setting the saved fields.
 DateTimeZone getDateTimeZone()
          Returns the time zone used by computeMillis, or null if an offset is used instead.
 long getOffset()
          Returns the time zone offset used by computeMillis, unless getDateTimeZone doesn't return null.
 void saveField(DateTimeField field, int value)
          Saves a datetime field value.
 void saveField(DateTimeField field, java.lang.String text, java.util.Locale locale)
          Saves a datetime field text value.
 java.lang.Object saveState()
          Saves the state of this bucket, returning it in an opaque object.
 void setDateTimeZone(DateTimeZone zone)
          Set a time zone to be used when computeMillis is called, which overrides any set time zone offset.
 void setOffset(int offset)
          Set a time zone offset to be used when computeMillis is called, which overrides the time zone.
 boolean undoChanges(java.lang.Object savedState)
          Undos any changes that were made to this bucket since the given state was saved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateTimeParserBucket

public DateTimeParserBucket(long millis)
Parameters:
millis - the initial millis from 1970-01-01T00:00:00, local time
Method Detail

getDateTimeZone

public DateTimeZone getDateTimeZone()
Returns the time zone used by computeMillis, or null if an offset is used instead.


setDateTimeZone

public void setDateTimeZone(DateTimeZone zone)
Set a time zone to be used when computeMillis is called, which overrides any set time zone offset.

Parameters:
zone - the date time zone to operate in, or null if UTC

getOffset

public long getOffset()
Returns the time zone offset used by computeMillis, unless getDateTimeZone doesn't return null.


setOffset

public void setOffset(int offset)
Set a time zone offset to be used when computeMillis is called, which overrides the time zone.


saveField

public void saveField(DateTimeField field,
                      int value)
Saves a datetime field value.


saveField

public void saveField(DateTimeField field,
                      java.lang.String text,
                      java.util.Locale locale)
Saves a datetime field text value.


saveState

public java.lang.Object saveState()
Saves the state of this bucket, returning it in an opaque object. Call undoChanges to undo any changes that were made since the state was saved. Calls to saveState may be nested.

Returns:
opaque saved state, which may be passed to undoChanges

undoChanges

public boolean undoChanges(java.lang.Object savedState)
Undos any changes that were made to this bucket since the given state was saved. Once the changes have been undone, they are lost. Any states that were saved after saving the previous state are also lost.

The state object passed into this method is not lost, and it can be used later to revert to that state again.

Parameters:
savedState - opaque saved state, returned from saveState
Returns:
true state object is valid and changes were undone

computeMillis

public long computeMillis()
Computes the parsed datetime by setting the saved fields. Calling this method does not affect the state of this object.

Returns:
milliseconds since 1970-01-01T00:00:00Z
Throws:
java.lang.IllegalArgumentException - if any field is out of range

Joda Time API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.