Clover coverage report - AdWT - 1.0.0
Coverage timestamp: sam. déc. 27 2003 15:14:10 CET
file stats: LOC: 85   Methods: 3
NCLOC: 49   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DateTimeEditor.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * EJTools, the Enterprise Java Tools
 3   
  *
 4   
  * Distributable under LGPL license.
 5   
  * See terms of license at www.gnu.org.
 6   
  */
 7   
 package org.ejtools.adwt.editor;
 8   
 
 9   
 import java.text.DateFormat;
 10   
 import java.text.ParseException;
 11   
 import java.text.SimpleDateFormat;
 12   
 import java.util.Date;
 13   
 
 14   
 /**
 15   
  * Description of the Class
 16   
  *
 17   
  * @author    Laurent Etiemble
 18   
  * @version   $Revision: 1.5 $
 19   
  * @todo      Javadoc to complete
 20   
  */
 21   
 public class DateTimeEditor extends GenericEditor
 22   
 {
 23   
    /** Description of the Field */
 24   
    protected DateFormat fmts[];
 25   
 
 26   
 
 27   
    /** Constructor for the DateEditor object */
 28  0
    public DateTimeEditor()
 29   
    {
 30  0
       fmts = new DateFormat[5];
 31  0
       fmts[0] = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
 32  0
       fmts[1] = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 33  0
       fmts[2] = new SimpleDateFormat("yyyy-MM-dd HH:mm");
 34  0
       fmts[3] = new SimpleDateFormat("yyMMdd HH:mm:ss");
 35  0
       fmts[4] = new SimpleDateFormat("yyMMdd HH:mm");
 36   
    }
 37   
 
 38   
 
 39   
    /**
 40   
     * Gets the asText attribute of the DateEditor object
 41   
     *
 42   
     * @return   The asText value
 43   
     */
 44  0
    public String getAsText()
 45   
    {
 46  0
       if (this.value != null)
 47   
       {
 48  0
          return this.fmts[0].format((Date) this.value);
 49   
       }
 50   
       else
 51   
       {
 52  0
          return "";
 53   
       }
 54   
    }
 55   
 
 56   
 
 57   
    /**
 58   
     * Sets the asText attribute of the DateEditor object
 59   
     *
 60   
     * @param s  The new asText value
 61   
     */
 62  0
    public void setAsText(String s)
 63   
    {
 64  0
       if (s.equals(""))
 65   
       {
 66  0
          this.value = null;
 67  0
          return;
 68   
       }
 69  0
       for (int i = 0; i < fmts.length; i++)
 70   
       {
 71  0
          try
 72   
          {
 73  0
             this.value = fmts[i].parse(s);
 74  0
             this.firePropertyChange();
 75  0
             return;
 76   
          }
 77   
          catch (ParseException pe)
 78   
          {
 79   
             // Do nothing
 80   
          }
 81   
       }
 82   
    }
 83   
 }
 84   
 
 85