01: /****************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one *
03: * or more contributor license agreements. See the NOTICE file *
04: * distributed with this work for additional information *
05: * regarding copyright ownership. The ASF licenses this file *
06: * to you under the Apache License, Version 2.0 (the *
07: * "License"); you may not use this file except in compliance *
08: * with the License. You may obtain a copy of the License at *
09: * *
10: * http://www.apache.org/licenses/LICENSE-2.0 *
11: * *
12: * Unless required by applicable law or agreed to in writing, *
13: * software distributed under the License is distributed on an *
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15: * KIND, either express or implied. See the License for the *
16: * specific language governing permissions and limitations *
17: * under the License. *
18: ****************************************************************/package org.apache.mailet.dates;
19:
20: import java.text.ParseException;
21: import java.util.Date;
22: import java.util.TimeZone;
23:
24: /**
25: * <p>This interface is designed to provide a simplified subset of the
26: * methods provided by the <code>java.text.DateFormat</code> class.</p>
27: *
28: * <p>This interface is necessary because of the difficulty in writing
29: * thread safe classes that inherit from <code>java.text.DateFormat</code>.
30: * This difficulty leads us to approach the problem using composition
31: * rather than inheritance. In general classes that implement this
32: * interface will delegate these calls to an internal DateFormat object.</p>
33: *
34: */
35: public interface SimplifiedDateFormat {
36:
37: /**
38: * Formats a Date into a date/time string.
39: * @param date the time value to be formatted into a time string.
40: * @return the formatted time string.
41: */
42: public String format(Date d);
43:
44: /**
45: * Parses text from the beginning of the given string to produce a date.
46: * The method may not use the entire text of the given string.
47: *
48: * @param source A <code>String</code> whose beginning should be parsed.
49: * @return A <code>Date</code> parsed from the string.
50: * @throws ParseException if the beginning of the specified string
51: * cannot be parsed.
52: */
53: public Date parse(String source) throws ParseException;
54:
55: /**
56: * Sets the time zone of this SimplifiedDateFormat object.
57: * @param zone the given new time zone.
58: */
59: public void setTimeZone(TimeZone zone);
60:
61: /**
62: * Gets the time zone.
63: * @return the time zone associated with this SimplifiedDateFormat.
64: */
65: public TimeZone getTimeZone();
66:
67: /**
68: * Specify whether or not date/time parsing is to be lenient. With
69: * lenient parsing, the parser may use heuristics to interpret inputs that
70: * do not precisely match this object's format. With strict parsing,
71: * inputs must match this object's format.
72: * @param lenient when true, parsing is lenient
73: * @see java.util.Calendar#setLenient
74: */
75: public void setLenient(boolean lenient);
76:
77: /**
78: * Tell whether date/time parsing is to be lenient.
79: * @return whether this SimplifiedDateFormat is lenient.
80: */
81: public boolean isLenient();
82: }
|