View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/filestore/common/src/java/org/astrogrid/filestore/common/FileStoreDateFormat.java,v $</cvs:source>
3    * <cvs:author>$Author: clq2 $</cvs:author>
4    * <cvs:date>$Date: 2005/01/28 10:43:58 $</cvs:date>
5    * <cvs:version>$Revision: 1.2 $</cvs:version>
6    * <cvs:log>
7    *   $Log: FileStoreDateFormat.java,v $
8    *   Revision 1.2  2005/01/28 10:43:58  clq2
9    *   dave_dev_200501141257 (filemanager)
10   *
11   *   Revision 1.1.2.2  2005/01/15 08:25:50  dave
12   *   Refactored file created and modified date handling ..
13   *
14   *   Revision 1.1.2.1  2005/01/14 21:01:33  dave
15   *   Added FileStoreDateFormat utility to handle dates in ISO format ....
16   *   Fixed the file:/// problem on Unix ...
17   *
18   * </cvs:log>
19   *
20   */
21  package org.astrogrid.filestore.common ;
22  
23  import java.util.Date;
24  import java.text.DateFormat;
25  import java.text.SimpleDateFormat;
26  import java.text.ParseException;
27  /***
28   * A utility class to handle date formatting.
29   *
30   */
31  public class FileStoreDateFormat
32  	extends SimpleDateFormat
33  	{
34  	/***
35  	 * The default date format.
36  	 *
37  	 */
38  	public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" ;
39  
40  	/***
41  	 * Public constructor.
42  	 *
43  	 */
44  	public FileStoreDateFormat()
45  		{
46  		super(
47  			DATE_FORMAT
48  			);
49  		}
50  
51  	/***
52  	 * Parse a string into a date.
53  	 * This just wraps the SimpleDateFormat method to make it capable of handling a null String.
54  	 * @param string The ISO format string, or null.
55  	 * @return A new Date generated from the String, or null if the string is null.
56  	 *
57  	 */
58  	public Date parse(String string)
59  		throws ParseException
60  		{
61  		if (null != string)
62  			{
63  			return super.parse(
64  				string
65  				);
66  			}
67  		else {
68  			return null ;
69  			}
70  		}
71  	}