org.apache.commons.convert
Class DateTimeConverters.DateToString

java.lang.Object
  extended by org.apache.commons.convert.AbstractConverter<S,T>
      extended by org.apache.commons.convert.AbstractLocalizedConverter<Date,String>
          extended by org.apache.commons.convert.DateTimeConverters.DateToString
All Implemented Interfaces:
Converter<Date,String>, ConverterLoader, LocalizedConverter<Date,String>
Enclosing class:
DateTimeConverters

public static class DateTimeConverters.DateToString
extends AbstractLocalizedConverter<Date,String>

An object that converts a java.util.Date to a String.


Constructor Summary
DateTimeConverters.DateToString()
           
 
Method Summary
 boolean canConvert(Class<?> sourceClass, Class<?> targetClass)
          Returns true if this object can convert sourceClass to targetClass.
 String convert(Date obj)
          Converts obj to a String formatted as DateTimeConverters.CALENDAR_FORMAT.
 String convert(Date obj, Locale locale, TimeZone timeZone, String formatString)
          Converts obj to a String using the supplied locale, time zone, and format string.
 
Methods inherited from class org.apache.commons.convert.AbstractLocalizedConverter
convert
 
Methods inherited from class org.apache.commons.convert.AbstractConverter
getSourceClass, getTargetClass, loadConverters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.convert.Converter
getSourceClass, getTargetClass
 

Constructor Detail

DateTimeConverters.DateToString

public DateTimeConverters.DateToString()
Method Detail

canConvert

public boolean canConvert(Class<?> sourceClass,
                          Class<?> targetClass)
Description copied from interface: Converter
Returns true if this object can convert sourceClass to targetClass.

Implementations can accomodate class hierarchy ranges by converting super classes or interfaces.

Specified by:
canConvert in interface Converter<Date,String>
Overrides:
canConvert in class AbstractConverter<Date,String>
Parameters:
sourceClass - The source Class
targetClass - The target Class
Returns:
true if this object can convert sourceClass to targetClass.

convert

public String convert(Date obj)
               throws ConversionException
Converts obj to a String formatted as DateTimeConverters.CALENDAR_FORMAT. The returned string is referenced to the default time zone.

Parameters:
obj - The source Object to convert
Returns:
The converted Object
Throws:
ConversionException

convert

public String convert(Date obj,
                      Locale locale,
                      TimeZone timeZone,
                      String formatString)
               throws ConversionException
Converts obj to a String using the supplied locale, time zone, and format string. If formatString is null, the string is formatted as DateTimeConverters.CALENDAR_FORMAT.

Parameters:
obj - The source Object to convert
locale - The locale used for conversion - must not be null
timeZone - The time zone used for conversion - must not be null
formatString - Optional formatting string
Returns:
The converted Object
Throws:
ConversionException


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.