Save This Page
Home » openjdk-7 » net.sourceforge.harness.xml » conversion » [javadoc | source]
    1   /*
    2    * The Harness API. Details can be found at: http://harness.dyndns.org
    3    * Copyright (C) 2000 - 2002, Marcel Schepers
    4    *
    5    * This library is free software; you can redistribute it and/or
    6    * modify it under the terms of the GNU Lesser General Public License
    7    * as published by the Free Software Foundation; either version 2.1
    8    * of the License, or (at your option) any later version.
    9    *
   10    * This library is distributed in the hope that it will be useful,
   11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13    * GNU Lesser General Public License for more details.
   14    *
   15    * You should have received a copy of the GNU Lesser General Public
   16    * License along with this library; if not, write to the Free
   17    * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   18    * 02111-1307  USA
   19    * package net.sourceforge.harness;
   20    */
   21   package net.sourceforge.harness.xml.conversion;
   22   
   23   import java.text.ParseException;
   24   import java.text.SimpleDateFormat;
   25   import java.util.Date;
   26   
   27   /**
   28    * Converts a java.util.Date to a java.lang.String and vice versa.
   29    *
   30    * <p><b>Usage:</b> <code>trivial</code>
   31    *
   32    * <p><b>History:</b>
   33    * <ul>
   34    *   <li>20011019, Initial file</li>
   35    * </ul>
   36    *
   37    * <p><b>CVS Information:</b><br>
   38    * <i>
   39    * $Date: 2002/10/09 13:11:32 $<br>
   40    * $Revision: 1.3 $<br>
   41    * $Author: mgl $<br>
   42    * </i>
   43    *
   44    * @author <a href="mailto:marcel.schepers@users.sourceforge.net>Marcel Schepers</a>
   45    */
   46   public class DateConverter {
   47     private static final String PATTERN = "yyyy/MM/dd HH:mm:ss:SSS";
   48     private static final SimpleDateFormat FORMAT = new SimpleDateFormat(PATTERN);
   49     
   50     public static Date parse(String date) throws ParseException{
   51       synchronized(FORMAT){
   52         return FORMAT.parse(date);
   53       }
   54     }
   55     
   56     public static String print(Date date){
   57       synchronized(FORMAT){
   58         return FORMAT.format(date);
   59       }
   60     }
   61   }

Save This Page
Home » openjdk-7 » net.sourceforge.harness.xml » conversion » [javadoc | source]