< prev index next >

src/java.xml/share/classes/javax/xml/datatype/XMLGregorianCalendar.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -26,10 +26,11 @@
 package javax.xml.datatype;
 
 import javax.xml.namespace.QName;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.util.Arrays;
 import java.util.TimeZone;
 import java.util.GregorianCalendar;
 
 /**
  * <p>Representation for W3C XML Schema 1.0 date/time datatypes.

@@ -714,16 +715,19 @@
         }
         XMLGregorianCalendar gc = this;
         if (timezone != 0) {
             gc = this.normalize();
         }
-        return gc.getYear()
-                + gc.getMonth()
-                + gc.getDay()
-                + gc.getHour()
-                + gc.getMinute()
-                + gc.getSecond();
+
+        BigInteger ey = gc.getEonAndYear();
+        int result = 31 + ((ey == null) ? 0 : ey.hashCode());
+        int[] elements = {gc.getMonth(), gc.getDay(), gc.getHour(),
+            gc.getMinute(), gc.getSecond()};
+        result = 31 * result + Arrays.hashCode(elements);
+        BigDecimal fs = gc.getFractionalSecond();
+        result = 31 * result + ((fs == null) ? 0 : fs.hashCode());
+        return result;
     }
 
     /**
      * Return the lexical representation of {@code this} instance.
      * The format is specified in
< prev index next >