Clover coverage report - Converter - 1.0
Coverage timestamp: Thu Jan 1 1970 10:00:00 EST
file stats: LOC: 72   Methods: 3
NCLOC: 30   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
StringToDateConverter.java - 0% 0% 0%
coverage
 1   
 /*
 2   
  * Copyright (C) The Spice Group. All rights reserved.
 3   
  *
 4   
  * This software is published under the terms of the Spice
 5   
  * Software License version 1.1, a copy of which has been included
 6   
  * with this distribution in the LICENSE.txt file.
 7   
  */
 8   
 package org.codehaus.spice.converter.lib;
 9   
 
 10   
 import java.text.DateFormat;
 11   
 import java.util.Date;
 12   
 import org.codehaus.spice.converter.AbstractConverter;
 13   
 import org.codehaus.spice.converter.ConverterException;
 14   
 
 15   
 /**
 16   
  * String to Date converter.
 17   
  *
 18   
  * <p>Parses a date according to the same rules as the Date.parse() method. In
 19   
  * particular it recognizes the IETF standard date syntax:</p>
 20   
  * <p>"Sat, 12 Aug 1995 13:30:00 GMT"</p>
 21   
  *
 22   
  * @author Peter Donald
 23   
  * @see java.util.Date#parse
 24   
  * @version $Revision: 1.1 $ $Date: 2003/12/02 08:37:56 $
 25   
  */
 26   
 public class StringToDateConverter
 27   
     extends AbstractConverter
 28   
 {
 29   
     /**
 30   
      * Construct the converter.
 31   
      */
 32  0
     public StringToDateConverter()
 33   
     {
 34  0
         this( null );
 35   
     }
 36   
 
 37   
     /**
 38   
      * Construct the converter with a default value.
 39   
      * If the default value is non-null, it will be returned if unable
 40   
      * to convert object to correct type.
 41   
      *
 42   
      * @param defaultValue the default value
 43   
      */
 44  0
     public StringToDateConverter( final Date defaultValue )
 45   
     {
 46  0
         super( String.class, Date.class, defaultValue );
 47   
     }
 48   
 
 49   
     /**
 50   
      * Converts a String to a Date.
 51   
      *
 52   
      * @param object the original object to convert
 53   
      * @param context the context in which to convert object (unused)
 54   
      * @return the converted object
 55   
      * @throws ConverterException if error converting object
 56   
      */
 57  0
     public Object convert( final Object object, final Object context )
 58   
         throws ConverterException
 59   
     {
 60  0
         try
 61   
         {
 62  0
             final DateFormat formatter = DateFormat.getInstance();
 63  0
             return formatter.format( object.toString() );
 64   
         }
 65   
         catch( final NumberFormatException nfe )
 66   
         {
 67  0
             return noConvert( object, nfe );
 68   
         }
 69   
     }
 70   
 }
 71   
 
 72