org.polliwog.fields
Class DateTimeField

java.lang.Object
  extended by org.polliwog.fields.AbstractField
      extended by org.polliwog.fields.DateTimeField

public class DateTimeField
extends AbstractField

A date/time field, this class allows representation of a date/time from the log entry. The date/time format that should be used is defined by passing the parameter: FORMAT to the init(Map,String) method, the format must conform to that defined in the java.text.SimpleDateFormat class.

Timezones are supported by passing the parameter: #TIMEZONE to the init(Map,String) method.

Example:

     DateTimeField dtf = new DateTimeField ();

     // Create the parms.
     Map params = new HashMap ();

     // The format used must conform to that defined in the java.text.SimpleDateFormat
     // class.
     params.put (DateTimeField.FORMAT,
                 "dd/MMM/yyyy:HH:mm:ss Z");
     params.put (DateTimeField.TIMEZONE,
                 "Australia/Brisbane");
 
     dft.init (params,
               value);
   
A future extension to this will probably allow for re-use of the SimpleDateFormat instance, perhaps by using a static variable.
 Last Modified By: $Author: barrygently $
 Last Modified On: $Date: 2005/07/04 14:00:02 $
 Current Revision: $Revision: 1.3 $
 


Field Summary
static java.util.Locale DEFAULT_LOCALE
           
static int FIELD_ID
          This is a unique constant for this field, it MUST NOT clash with any other field constant value otherwise incorrect casting may result.
static java.lang.String FORMAT
           
static java.lang.String LOCALE
           
 
Constructor Summary
DateTimeField()
           
 
Method Summary
 void clear()
          Clear the data that the field holds.
 java.util.Date getDate()
          Get the date created from the field value.
 int getFieldId()
          Should return a unique id for this field, this is to help with classes (such as: Hit) that use this id to help in identification.
 void init(java.util.Map params, java.lang.String value)
          Init the field with the date/time value.
 java.lang.String toString()
          Get a string representation of the date, just returns Date.toString.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIELD_ID

public static final int FIELD_ID
This is a unique constant for this field, it MUST NOT clash with any other field constant value otherwise incorrect casting may result.

See Also:
Constant Field Values

DEFAULT_LOCALE

public static final java.util.Locale DEFAULT_LOCALE

FORMAT

public static final java.lang.String FORMAT
See Also:
Constant Field Values

LOCALE

public static final java.lang.String LOCALE
See Also:
Constant Field Values
Constructor Detail

DateTimeField

public DateTimeField()
Method Detail

clear

public void clear()
Description copied from class: AbstractField
Clear the data that the field holds.

Specified by:
clear in class AbstractField

getDate

public java.util.Date getDate()
Get the date created from the field value.

Returns:
The date.

toString

public java.lang.String toString()
Get a string representation of the date, just returns Date.toString.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the date.

init

public void init(java.util.Map params,
                 java.lang.String value)
          throws WeblogException
Init the field with the date/time value.

The params Map must contain a FORMAT entry that maps to a date/time format spec (that conforms to that defined in the java.text.SimpleDateFormat class). It is that format that is used to parse the value parm.

An optional #TIMEZONE param is also supported which should map to a valid timezone.

Specified by:
init in class AbstractField
Parameters:
params - A Map of name/value pairs that hold configuration values.
value - The value to convert to a date/time.
Throws:
WeblogException - Throw if something is wrong with the value.

getFieldId

public int getFieldId()
Description copied from class: AbstractField
Should return a unique id for this field, this is to help with classes (such as: Hit) that use this id to help in identification.

Specified by:
getFieldId in class AbstractField
Returns:
A unique id.


  Copyright © 2007 Gary Bentley. All Rights Reserved.