org.compass.core.converter.basic
Class DateConverter

java.lang.Object
  extended by org.compass.core.converter.basic.AbstractBasicConverter
      extended by org.compass.core.converter.basic.AbstractFormatConverter
          extended by org.compass.core.converter.basic.DateConverter
All Implemented Interfaces:
CompassConfigurable, FormatConverter, Converter, ResourcePropertyConverter
Direct Known Subclasses:
CalendarConverter, SqlDateConverter, SqlTimeConverter, SqlTimestampConverter

public class DateConverter
extends AbstractFormatConverter

Converts dates to String and vice versa. Supports the notion of "now" using DateMathParser.

Author:
kimchy

Field Summary
static String DEFAULT_DATE_FORMAT
           
static String DEFAULT_NOW_PREFIX
           
 
Fields inherited from class org.compass.core.converter.basic.AbstractFormatConverter
formatters, hasFormatter, locale
 
Constructor Summary
DateConverter()
           
 
Method Summary
protected  ThreadSafeFormat.FormatterFactory doCreateFormatterFactory()
           
protected  String doGetDefaultFormat()
           
 Object fromString(String str, ResourcePropertyMapping resourcePropertyMapping)
          Try all the configured formatters to format the str into an Object.
 String toString(Object o, ResourcePropertyMapping resourcePropertyMapping)
          Uses the first configured formatter (also known as the default one) to convert it to String.
 
Methods inherited from class org.compass.core.converter.basic.AbstractFormatConverter
canNormalize, configure, copy, setFormat
 
Methods inherited from class org.compass.core.converter.basic.AbstractBasicConverter
createProperty, doSetBoost, fromString, getNullValue, handleNulls, isNullValue, marshall, toString, unmarshall
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.compass.core.converter.Converter
marshall, unmarshall
 

Field Detail

DEFAULT_NOW_PREFIX

public static final String DEFAULT_NOW_PREFIX
See Also:
Constant Field Values

DEFAULT_DATE_FORMAT

public static final String DEFAULT_DATE_FORMAT
See Also:
Constant Field Values
Constructor Detail

DateConverter

public DateConverter()
Method Detail

doGetDefaultFormat

protected String doGetDefaultFormat()
Overrides:
doGetDefaultFormat in class AbstractFormatConverter

doCreateFormatterFactory

protected ThreadSafeFormat.FormatterFactory doCreateFormatterFactory()
Specified by:
doCreateFormatterFactory in class AbstractFormatConverter

fromString

public Object fromString(String str,
                         ResourcePropertyMapping resourcePropertyMapping)
                  throws ConversionException
Try all the configured formatters to format the str into an Object.

Parameters:
str - The string to convert from
resourcePropertyMapping - The resource property mapping
Returns:
Theh object converterd from the String
Throws:
ConversionException

toString

public String toString(Object o,
                       ResourcePropertyMapping resourcePropertyMapping)
                throws ConversionException
Uses the first configured formatter (also known as the default one) to convert it to String.

Specified by:
toString in interface ResourcePropertyConverter
Overrides:
toString in class AbstractBasicConverter
Parameters:
o - The Object to convert from
resourcePropertyMapping - The resource proeprty mapping
Returns:
The String converted from the Object
Throws:
ConversionException


Copyright (c) 2004-2006 The Compass Project.