Hans,

The NPE is by design. Calling code should validate parameters before calling the utility method.

Providing undocumented default values will also cause strange behavior.

-Adrian

On 11/24/2011 2:54 AM, [email protected] wrote:
Author: hansbak
Date: Thu Nov 24 02:54:14 2011
New Revision: 1205710

URL: http://svn.apache.org/viewvc?rev=1205710&view=rev
Log:
getDayEnd will have a null pointer exception when the offset is not provided. 
This can cause very strange behaviour in the system when people forget to enter 
a value in terms. When not provided zero is assumed now

Modified:
     ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java?rev=1205710&r1=1205709&r2=1205710&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java 
(original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java Thu 
Nov 24 02:54:14 2011
@@ -823,6 +823,9 @@ public class UtilDateTime {
      }

      public static Timestamp getDayEnd(Timestamp stamp, Long daysLater, 
TimeZone timeZone, Locale locale) {
+       if (daysLater == null) {
+               daysLater = Long.valueOf(0);
+       }
          Calendar tempCal = toCalendar(stamp, timeZone, locale);
          tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), 
tempCal.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
          tempCal.add(Calendar.DAY_OF_MONTH, daysLater.intValue());


Reply via email to