Re: svn commit: r604898 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r604898 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java

Adrian Crum
Hans,

Did you read my last email on this subject? Your methods will not work properly. Please use the

UtilDateTime.adjustTimestamp(Timestamp stamp, int adjType, int adjQuantity, TimeZone timeZone,
Locale locale)

method.

-Adrian

[hidden email] wrote:

> Author: hansbak
> Date: Mon Dec 17 07:24:46 2007
> New Revision: 604898
>
> URL: http://svn.apache.org/viewvc?rev=604898&view=rev
> Log:
> another small day calculation class to be used in minilanguage
>
> Modified:
>     ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java
>
> Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java?rev=604898&r1=604897&r2=604898&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java (original)
> +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java Mon Dec 17 07:24:46 2007
> @@ -83,6 +83,10 @@
>          return new Timestamp(start.getTime() + (24*60*60*1000*days));
>      }
>  
> +    public static Timestamp addDaysToTimestamp(Timestamp start, Double days) {
> +        return new Timestamp(start.getTime() + ((int) (24*60*60*1000*days)));
> +    }
> +
>      public static double getInterval(Timestamp from, Timestamp thru) {
>          return thru != null ? thru.getTime() - from.getTime() + (thru.getNanos() - from.getNanos()) / 1000000 : 0;
>      }
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r604898 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java

David E Jones

I was going to comment on this too. As Adrian has expressed a number  
of times using millisecond calculations is not reliable and the  
Calendar or similar objects should be used instead.

-David


On Dec 17, 2007, at 8:40 AM, Adrian Crum wrote:

> Hans,
>
> Did you read my last email on this subject? Your methods will not  
> work properly. Please use the
>
> UtilDateTime.adjustTimestamp(Timestamp stamp, int adjType, int  
> adjQuantity, TimeZone timeZone, Locale locale)
>
> method.
>
> -Adrian
>
> [hidden email] wrote:
>
>> Author: hansbak
>> Date: Mon Dec 17 07:24:46 2007
>> New Revision: 604898
>> URL: http://svn.apache.org/viewvc?rev=604898&view=rev
>> Log:
>> another small day calculation class to be used in minilanguage
>> Modified:
>>    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/
>> UtilDateTime.java
>> Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/
>> UtilDateTime.java
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java?rev=604898&r1=604897&r2=604898&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/
>> UtilDateTime.java (original)
>> +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/
>> UtilDateTime.java Mon Dec 17 07:24:46 2007
>> @@ -83,6 +83,10 @@
>>         return new Timestamp(start.getTime() + (24*60*60*1000*days));
>>     }
>> +    public static Timestamp addDaysToTimestamp(Timestamp start,  
>> Double days) {
>> +        return new Timestamp(start.getTime() + ((int)  
>> (24*60*60*1000*days)));
>> +    }
>> +
>>     public static double getInterval(Timestamp from, Timestamp  
>> thru) {
>>         return thru != null ? thru.getTime() - from.getTime() +  
>> (thru.getNanos() - from.getNanos()) / 1000000 : 0;
>>     }
>


smime.p7s (3K) Download Attachment