KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > util > SimplifiedDateFormat


1 /***********************************************************************
2  * Copyright (c) 2000-2004 The Apache Software Foundation. *
3  * All rights reserved. *
4  * ------------------------------------------------------------------- *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you *
6  * may not use this file except in compliance with the License. You *
7  * may obtain a copy of the License at: *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
14  * implied. See the License for the specific language governing *
15  * permissions and limitations under the License. *
16  ***********************************************************************/

17
18 package org.apache.james.util;
19
20 import java.text.ParseException JavaDoc;
21 import java.util.Date JavaDoc;
22 import java.util.Locale JavaDoc;
23 import java.util.TimeZone JavaDoc;
24
25 /**
26  * <p>This interface is designed to provide a simplified subset of the
27  * methods provided by the <code>java.text.DateFormat</code> class.</p>
28  *
29  * <p>This interface is necessary because of the difficulty in writing
30  * thread safe classes that inherit from <code>java.text.DateFormat</code>.
31  * This difficulty leads us to approach the problem using composition
32  * rather than inheritance. In general classes that implement this
33  * interface will delegate these calls to an internal DateFormat object.</p>
34  *
35  */

36 public interface SimplifiedDateFormat {
37
38     /**
39      * Formats a Date into a date/time string.
40      * @param date the time value to be formatted into a time string.
41      * @return the formatted time string.
42      */

43     public String JavaDoc format(Date JavaDoc d);
44
45     /**
46      * Parses text from the beginning of the given string to produce a date.
47      * The method may not use the entire text of the given string.
48      *
49      * @param source A <code>String</code> whose beginning should be parsed.
50      * @return A <code>Date</code> parsed from the string.
51      * @throws ParseException if the beginning of the specified string
52      * cannot be parsed.
53      */

54     public Date JavaDoc parse(String JavaDoc source) throws ParseException JavaDoc;
55
56     /**
57      * Sets the time zone of this SimplifiedDateFormat object.
58      * @param zone the given new time zone.
59      */

60     public void setTimeZone(TimeZone JavaDoc zone);
61
62     /**
63      * Gets the time zone.
64      * @return the time zone associated with this SimplifiedDateFormat.
65      */

66     public TimeZone JavaDoc getTimeZone();
67
68     /**
69      * Specify whether or not date/time parsing is to be lenient. With
70      * lenient parsing, the parser may use heuristics to interpret inputs that
71      * do not precisely match this object's format. With strict parsing,
72      * inputs must match this object's format.
73      * @param lenient when true, parsing is lenient
74      * @see java.util.Calendar#setLenient
75      */

76     public void setLenient(boolean lenient);
77
78     /**
79      * Tell whether date/time parsing is to be lenient.
80      * @return whether this SimplifiedDateFormat is lenient.
81      */

82     public boolean isLenient();
83 }
84
85
Popular Tags