Question regarding durations and calculations of invoices

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Question regarding durations and calculations of invoices

Todd Nine
Hi guys,
  I'm new to Joda Time.  It's a great API, I'm using it calculate date ranges for customers and their data usage.  We define usage periods as "1 month".

For instance, if a user registers on Jan1, this would be their invoice durations

Jan1 -> Feb 1
Feb1 -> March 1
March 1 -> April 1

However, when registering towards the end of the month, this becomes tricky

Jan 31 -> Feb 28
Feb28 -> March 31
March 31 -> April 30


Is there an easy way to calculate this via Joda time?

Thanks,
Todd

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question regarding durations and calculations of invoices

jodastephen
If you add a period of 1 month Joda-Time will adjust the day if
necessary, which handles these cases
Jan 31 -> Feb 28
March 31 -> April 30

However, Joda-Time does not handle these cases, so you'll need manual
logic for 5 of the months:
Feb 28 -> March 31
Apr 30 -> May 31

Stephen


On 6 September 2011 06:28, Todd Nine <[hidden email]> wrote:

> Hi guys,
>   I'm new to Joda Time.  It's a great API, I'm using it calculate date
> ranges for customers and their data usage.  We define usage periods as "1
> month".
>
> For instance, if a user registers on Jan1, this would be their invoice
> durations
>
> Jan1 -> Feb 1
> Feb1 -> March 1
> March 1 -> April 1
>
> However, when registering towards the end of the month, this becomes tricky
>
> Jan 31 -> Feb 28
> Feb28 -> March 31
> March 31 -> April 30
>
>
> Is there an easy way to calculate this via Joda time?
>
> Thanks,
> Todd
>
> ------------------------------------------------------------------------------
> Special Offer -- Download ArcSight Logger for FREE!
> Finally, a world-class log management solution at an even better
> price-free! And you'll get a free "Love Thy Logs" t-shirt when you
> download Logger. Secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsisghtdev2dev
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>
>

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question regarding durations and calculations of invoices

Todd Nine
Hi Stephen,
  I was thinking about this last night.  It seems that given the way Joda time uses Periods, I should be able to use a Period to calculate a delta between the first run date and the current date, then apply that delta in months to the first run date, which creates the correct rolling start end date.  I've linked to the source here in case anyone wants to take a look at how I did it.  We use monthly rolling calculations based on when the user signed up.

Months = created Date Time - current DateTime

New Range

created Date Time + Months


Here is the source I used

https://gist.github.com/395c8b9814e089602e9c



On 6 September 2011 18:59, Stephen Colebourne <[hidden email]> wrote:
If you add a period of 1 month Joda-Time will adjust the day if
necessary, which handles these cases
Jan 31 -> Feb 28
March 31 -> April 30

However, Joda-Time does not handle these cases, so you'll need manual
logic for 5 of the months:
Feb 28 -> March 31
Apr 30 -> May 31

Stephen


On 6 September 2011 06:28, Todd Nine <[hidden email]> wrote:
> Hi guys,
>   I'm new to Joda Time.  It's a great API, I'm using it calculate date
> ranges for customers and their data usage.  We define usage periods as "1
> month".
>
> For instance, if a user registers on Jan1, this would be their invoice
> durations
>
> Jan1 -> Feb 1
> Feb1 -> March 1
> March 1 -> April 1
>
> However, when registering towards the end of the month, this becomes tricky
>
> Jan 31 -> Feb 28
> Feb28 -> March 31
> March 31 -> April 30
>
>
> Is there an easy way to calculate this via Joda time?
>
> Thanks,
> Todd
>
> ------------------------------------------------------------------------------
> Special Offer -- Download ArcSight Logger for FREE!
> Finally, a world-class log management solution at an even better
> price-free! And you'll get a free "Love Thy Logs" t-shirt when you
> download Logger. Secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsisghtdev2dev
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>
>

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest


------------------------------------------------------------------------------
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...