[jira] Created: (OFBIZ-715) Utils for doing data calculations based on timeUomIds

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

[jira] Commented: (OFBIZ-715) Utils for doing date calculations based on timeUomIds

Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12586135#action_12586135 ]

Adrian Crum commented on OFBIZ-715:
-----------------------------------

Valentina,

Leap years and leap seconds are handled by the Java Calendar and TimeZone classes automatically.

This issue is concerned with elapsed time and how to compute it using the Java Calendar class. It made sense to me to have it behave in the same but opposite manner as the date/time calculations performed in the Calendar class. For example, if a Calendar instance is initialized to March 31, then you set the month to -1 (subtract one month) the result will be February 28 or 29 - depending on the year. Conversely, given two Calendar instances, one initialized to February 28 and the other initialized to March 31, the elapsed time should be one month. The class I developed performs the calculation pretty well, but there are exceptions where the elapsed time is not what you would expect.


> Utils for doing date calculations based on timeUomIds
> -----------------------------------------------------
>
>                 Key: OFBIZ-715
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-715
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Andrew Sykes
>            Assignee: Jacques Le Roux
>            Priority: Minor
>         Attachments: elapsed_time.patch, UtilDateTime.java.patch, UtilDateTime.java.patch
>
>
> 6 new methods,
> 1/ adjustDateTime (3 methods) adjusts either a Timestamp Date or Calendar by the given timeUomId and timeUomMultiple
> 2/ getTimeUomMultipleDifference (3 methods) gets the timeUomMultiple for two Timestamp Date or Calendar objects given the timeUomId.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-715) Utils for doing date calculations based on timeUomIds

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12586163#action_12586163 ]

Valentina Sirkova commented on OFBIZ-715:
-----------------------------------------

Hi Adrian - thanks a lot for answering,

Yes I reviewed your ElapsedTime patch and of course totally agree we should use java Calendar class and loop approach for solving the issue.
My question was slightly different. When we use Calendar`s "add" methods for adding years,months etc. we might have the following situation-calculate the years, months and days between: 2000-02-29 and 2004-02-29.
Using the callendar`s add method for calculating the year for example you would get 4 years and 1 day because doing calStart.add(Calendar.YEAR, 1) would give :
 - 2001-Feb-28(because Feb 29 does not exist!)
 - 2002-Feb-28
 - 2003-Feb-28
 - 2004-Feb-28
So I wonder if this is correct because I think the elapsed time is 4 years and NOT 4 years and 1 day. ?And if it really is 4 years for such period 29Feb-29Feb AND we assume the difference between 29Feb-28Feb is ONE year (as you say in your previous comment) then wouldn`t that mean that when we have the Leap day in ANY of our start and end dates we would always have a whole year?
This would be exactly 3 cases: 29Feb-29Feb, 29Feb-28Feb, 28Feb-29Feb
If we think of these periods as days elapsed this should be true as year could be 366 and 365 days...but I am not sure and need your advice..

Thanks: Valentina :)

> Utils for doing date calculations based on timeUomIds
> -----------------------------------------------------
>
>                 Key: OFBIZ-715
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-715
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Andrew Sykes
>            Assignee: Jacques Le Roux
>            Priority: Minor
>         Attachments: elapsed_time.patch, UtilDateTime.java.patch, UtilDateTime.java.patch
>
>
> 6 new methods,
> 1/ adjustDateTime (3 methods) adjusts either a Timestamp Date or Calendar by the given timeUomId and timeUomMultiple
> 2/ getTimeUomMultipleDifference (3 methods) gets the timeUomMultiple for two Timestamp Date or Calendar objects given the timeUomId.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (OFBIZ-715) Utils for doing date calculations based on timeUomIds

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-715?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adrian Crum closed OFBIZ-715.
-----------------------------

    Resolution: Fixed

Elapsed time calculation added to org.ofbiz.base.util.TimeDuration class in rev 698055.

> Utils for doing date calculations based on timeUomIds
> -----------------------------------------------------
>
>                 Key: OFBIZ-715
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-715
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Andrew Sykes
>            Assignee: Jacques Le Roux
>            Priority: Minor
>         Attachments: elapsed_time.patch, UtilDateTime.java.patch, UtilDateTime.java.patch
>
>
> 6 new methods,
> 1/ adjustDateTime (3 methods) adjusts either a Timestamp Date or Calendar by the given timeUomId and timeUomMultiple
> 2/ getTimeUomMultipleDifference (3 methods) gets the timeUomMultiple for two Timestamp Date or Calendar objects given the timeUomId.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

12