Class FormattingDateConvertor

  extended by org.apache.cocoon.woody.datatype.convertor.FormattingDateConvertor
All Implemented Interfaces:

public class FormattingDateConvertor
extends Object
implements Convertor

A Convertor for Date objects backed by the SimpleDateFormat class.

It can be configured to use one of three variants: date, time or datetime and one of four styles: long, full, medium or short.

Alternatively, a formatting pattern can be used. This can either be a locale-dependent or locale-independent formatting pattern. When looking up a formatting pattern, a mechansim similar to resource bundle lookup is used. Suppose the locale is nl-BE, then first a formatting pattern for nl-BE will be sought, then one for nl, and if that is not found, finally the locale-independent formatting pattern will be used.

NOTE: the earlier statement about the fact that this class uses java.text.SimpleDateFormat is not entirely correct. In fact, it uses a small wrapper class that will either delegate to java.text.SimpleDateFormat or The version will automatically be used if it is present on the classpath, otherwise the java.text version will be used.

CVS $Id: FormattingDateConvertor.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cocoon.woody.datatype.convertor.Convertor
Field Summary
static int DATE
static int DATE_TIME
static int TIME
Constructor Summary
Method Summary
 void addFormattingPattern(Locale locale, String pattern)
 Object convertFromString(String value, Locale locale, Convertor.FormatCache formatCache)
          Converts string representation into the object of convertor's type.
 String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache)
protected  DateFormat getDateFormat(Locale locale)
 Class getTypeClass()
 void setNonLocalizedPattern(String pattern)
 void setStyle(int style)
 void setVariant(int variant)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final int DATE
See Also:
Constant Field Values


public static final int TIME
See Also:
Constant Field Values


public static final int DATE_TIME
See Also:
Constant Field Values
Constructor Detail


public FormattingDateConvertor()
Method Detail


public Object convertFromString(String value,
                                Locale locale,
                                Convertor.FormatCache formatCache)
Description copied from interface: Convertor
Converts string representation into the object of convertor's type. Returns null if conversion fails.

Specified by:
convertFromString in interface Convertor
formatCache - can be null if not needed


public String convertToString(Object value,
                              Locale locale,
                              Convertor.FormatCache formatCache)
Specified by:
convertToString in interface Convertor


protected DateFormat getDateFormat(Locale locale)


public Class getTypeClass()
Specified by:
getTypeClass in interface Convertor


public void setStyle(int style)
style - one of the constants FULL, LONG, MEDIUM or SHORT defined in the Date class.


public void setVariant(int variant)


public void addFormattingPattern(Locale locale,
                                 String pattern)


public void setNonLocalizedPattern(String pattern)

Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.