commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r664643 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/time/DateUtils.java
Date Mon, 09 Jun 2008 07:17:24 GMT
Author: bayard
Date: Mon Jun  9 00:17:24 2008
New Revision: 664643

URL: http://svn.apache.org/viewvc?rev=664643&view=rev
Log:
Applying Robert Scholte's fix for LANG-440, replicating the SEMI_MONTH logic for AM_PM requests

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/time/DateUtils.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/time/DateUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/time/DateUtils.java?rev=664643&r1=664642&r2=664643&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/time/DateUtils.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/time/DateUtils.java Mon Jun
 9 00:17:24 2008
@@ -829,6 +829,18 @@
                                 val.add(Calendar.DATE, -15);
                                 val.add(Calendar.MONTH, 1);
                             }
+// ----------------- Fix for LANG-440 ---------------------- START ---------------
+                        } else if (field == Calendar.AM_PM) {
+                            // This is a special case
+                            // If the time is 0, we round up to 12, otherwise
+                            //  we subtract 12 hours and add 1 day
+                            if (val.get(Calendar.HOUR_OF_DAY) == 0) {
+                                val.add(Calendar.HOUR_OF_DAY, 12);
+                            } else {
+                                val.add(Calendar.HOUR_OF_DAY, -12);
+                                val.add(Calendar.DATE, 1);
+                            }
+// ----------------- Fix for LANG-440 ---------------------- END ---------------
                         } else {
                             //We need at add one to this field since the
                             //  last number causes us to round up



Mime
View raw message