You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2009/05/27 01:48:21 UTC

svn commit: r778929 - in /xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans: GDate.java GDateBuilder.java

Author: cezar
Date: Tue May 26 23:48:20 2009
New Revision: 778929

URL: http://svn.apache.org/viewvc?rev=778929&view=rev
Log:
Fix for 24h time when using setTime in GDateBuilder.


Modified:
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDate.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDateBuilder.java

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDate.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDate.java?rev=778929&r1=778928&r2=778929&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDate.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDate.java Tue May 26 23:48:20 2009
@@ -267,7 +267,7 @@
         if ( hasTime() && _h == 24 )
         {
             if ( _m != 0 || _s != 0 || _fs.compareTo(_zero) != 0 )
-                throw new IllegalArgumentException("if hour is 24 minutes, seconds and fraction must be 0");
+                throw new IllegalArgumentException("if hour is 24, minutes, seconds and fraction must be 0");
             else
             {   // normalize to next day if it has date or at least has day
                 if ( hasDate() )

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDateBuilder.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDateBuilder.java?rev=778929&r1=778928&r2=778929&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDateBuilder.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/GDateBuilder.java Tue May 26 23:48:20 2009
@@ -414,14 +414,14 @@
      * minutes and seconds range from 0 to 59; and fractional
      * seconds range from 0 (inclusive) to 1 (exclusive).
      * The fraction can be null and is assumed to be zero.
-     * @param hour the hour of day, from 0-23
+     * @param hour the hour of day, from 0-23 or 24 only if min, sec and fraction are 0
      * @param minute the minute of hour, from 0-59
      * @param second the second of minute, from 0-59
      * @param fraction the fraction of second, 0.0 to 0.999... (may be null)
      */
     public void setTime(int hour, int minute, int second, BigDecimal fraction)
     {
-        if (hour < 0 || hour > 23)
+        if (hour < 0 || hour > 24 )
             throw new IllegalArgumentException("hour out of range");
         if (minute < 0 || minute > 59)
             throw new IllegalArgumentException("minute out of range");
@@ -429,6 +429,9 @@
             throw new IllegalArgumentException("second out of range");
         if (fraction != null && (fraction.signum() < 0 || fraction.compareTo(GDate._one) > 1))
             throw new IllegalArgumentException("fraction out of range");
+        if ( hour == 24 && (minute!=0 || second!=0 || (fraction!=null && (GDate._zero.compareTo(fraction)!=0)) ))
+            throw new IllegalArgumentException("when hour is 24, min sec and fracton must be 0");
+
         _bits |= HAS_TIME;
         _h = hour;
         _m = minute;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org