summaryrefslogtreecommitdiff
path: root/java/text/DateFormat.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/text/DateFormat.java')
-rw-r--r--java/text/DateFormat.java56
1 files changed, 41 insertions, 15 deletions
diff --git a/java/text/DateFormat.java b/java/text/DateFormat.java
index 14f7cb9b1..5d412aada 100644
--- a/java/text/DateFormat.java
+++ b/java/text/DateFormat.java
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -405,8 +405,18 @@ public abstract class DateFormat extends Format implements Cloneable
* <ul>
* <li>Is not <code>null</code>.</li>
* <li>Is an instance of <code>DateFormat</code>.</li>
- * <li>Has the same numberFormat field value as this object.</li>
+ * <li>Has equal numberFormat field as this object.</li>
+ * <li>Has equal (Calendar) TimeZone rules as this object.</li>
+ * <li>Has equal (Calendar) isLenient results.</li>
+ * <li>Has equal Calendar first day of week and minimal days in week
+ * values.</li>
* </ul>
+ * Note that not all properties of the Calendar are relevant for a
+ * DateFormat. For formatting only the fact whether or not the
+ * TimeZone has the same rules and whether the calendar is lenient
+ * and has the same week rules is compared for this implementation
+ * of equals. Other properties of the Calendar (such as the time)
+ * are not taken into account.
*
* @param obj The object to test for equality against.
*
@@ -419,8 +429,24 @@ public abstract class DateFormat extends Format implements Cloneable
return false;
DateFormat d = (DateFormat) obj;
-
- return numberFormat.equals(d.numberFormat);
+ TimeZone tz = getTimeZone();
+ TimeZone tzd = d.getTimeZone();
+ if (tz.hasSameRules(tzd))
+ if (isLenient() == d.isLenient())
+ {
+ Calendar c = getCalendar();
+ Calendar cd = d.getCalendar();
+ if ((c == null && cd == null)
+ ||
+ (c.getFirstDayOfWeek() == cd.getFirstDayOfWeek()
+ &&
+ c.getMinimalDaysInFirstWeek()
+ == cd.getMinimalDaysInFirstWeek()))
+ return ((numberFormat == null && d.numberFormat == null)
+ || numberFormat.equals(d.numberFormat));
+ }
+
+ return false;
}
/**
@@ -442,9 +468,9 @@ public abstract class DateFormat extends Format implements Cloneable
* thrown.
*
* @param obj The <code>Object</code> to format.
- * @param toAppendTo The <code>StringBuffer</code> to append the resultant
+ * @param buf The <code>StringBuffer</code> to append the resultant
* <code>String</code> to.
- * @param fieldPosition Is updated to the start and end index of the
+ * @param pos Is updated to the start and end index of the
* specified field.
*
* @return The <code>StringBuffer</code> supplied on input, with the
@@ -479,9 +505,9 @@ public abstract class DateFormat extends Format implements Cloneable
* to the specified <code>StringBuffer</code>.
*
* @param date The <code>Date</code> value to format.
- * @param toAppendTo The <code>StringBuffer</code> to append the resultant
+ * @param buf The <code>StringBuffer</code> to append the resultant
* <code>String</code> to.
- * @param fieldPosition Is updated to the start and end index of the
+ * @param pos Is updated to the start and end index of the
* specified field.
*
* @return The <code>StringBuffer</code> supplied on input, with the
@@ -643,7 +669,7 @@ public abstract class DateFormat extends Format implements Cloneable
* localed will be used in place of the default.
*
* @param style The type of formatting to perform.
- * @param aLocale The desired locale.
+ * @param loc The desired locale.
*
* @return A new <code>DateFormat</code> instance.
*/
@@ -744,7 +770,7 @@ public abstract class DateFormat extends Format implements Cloneable
* localed will be used in place of the default.
*
* @param style The type of formatting to perform.
- * @param aLocale The desired locale.
+ * @param loc The desired locale.
*
* @return A new <code>DateFormat</code> instance.
*/
@@ -818,7 +844,7 @@ public abstract class DateFormat extends Format implements Cloneable
* starting parse position on method entry and the ending parse
* position on method exit.
*
- * @param text The string to parse.
+ * @param source The string to parse.
* @param pos The starting parse position in entry, the ending parse
* position on exit.
*
@@ -848,7 +874,7 @@ public abstract class DateFormat extends Format implements Cloneable
* This method specified the <code>Calendar</code> that should be used
* by this object to parse/format datetimes.
*
- * @param The new <code>Calendar</code> for this object.
+ * @param calendar The new <code>Calendar</code> for this object.
*
* @see java.util.Calendar
*/
@@ -873,7 +899,7 @@ public abstract class DateFormat extends Format implements Cloneable
* This method specifies the <code>NumberFormat</code> object that should
* be used by this object to parse/format times.
*
- * @param The <code>NumberFormat</code> in use by this object.
+ * @param numberFormat The <code>NumberFormat</code> in use by this object.
*/
public void setNumberFormat (NumberFormat numberFormat)
{
@@ -883,7 +909,7 @@ public abstract class DateFormat extends Format implements Cloneable
/**
* This method sets the time zone that should be used by this object.
*
- * @param The new time zone.
+ * @param timeZone The new time zone.
*/
public void setTimeZone (TimeZone timeZone)
{