net.ramapuram.thomas.util
Class DateConverter

java.lang.Object
  extended by net.ramapuram.thomas.util.DateConverter
All Implemented Interfaces:
org.apache.commons.beanutils.Converter
Direct Known Subclasses:
TimestampConverter

public class DateConverter
extends java.lang.Object
implements org.apache.commons.beanutils.Converter

This class converts a java.util.Date to a String and a String to a java.util.Date.

Author:
Matt Raible, Tibor Strausz

Constructor Summary
DateConverter()
           
 
Method Summary
 java.lang.Object convert(java.lang.Class type, java.lang.Object value)
          Convert a date to a String and a String to a Date
protected  java.lang.Object convertToDate(java.lang.Class<?> type, java.lang.Object value, java.lang.String pattern)
          Convert a String to a Date with the specified pattern.
protected  java.lang.Object convertToString(java.lang.Object value)
          Convert a java.util.Date or a java.sql.Timestamp to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateConverter

public DateConverter()
Method Detail

convert

public java.lang.Object convert(java.lang.Class type,
                                java.lang.Object value)
Convert a date to a String and a String to a Date

Specified by:
convert in interface org.apache.commons.beanutils.Converter
Parameters:
type - String, Date or Timestamp
value - value to convert
Returns:
Converted value for property population

convertToDate

protected java.lang.Object convertToDate(java.lang.Class<?> type,
                                         java.lang.Object value,
                                         java.lang.String pattern)
Convert a String to a Date with the specified pattern.

Parameters:
type - String
value - value of String
pattern - date pattern to parse with
Returns:
Converted value for property population

convertToString

protected java.lang.Object convertToString(java.lang.Object value)
Convert a java.util.Date or a java.sql.Timestamp to a String. Or does a toString

Parameters:
value - value to convert
Returns:
Converted value for property population


Copyright © 2011. All Rights Reserved.