1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 }