Fractional Years Difference

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

Fractional Years Difference

James Richardson-2

Hi,

If i want to calculate, say, simple interest, then I need the number of
years that the principal has been held, generally as a fractional number.

How can I get Joda Time to give me this fractional number?

Days.daysBetween(x,y) - gives number of days, but cnoverting this to real
years is different.

Years.yearsBetween(x,y) - gives only whole years.

new Period(x,y) - not sure how this helps me here...

Also, years with leap years would seem to complicate any "naive" solution.

I'm sure this gets done a lot, so any help much appreciated.


Thanks!

James



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
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: Fractional Years Difference

jodastephen
Joda-Time has no solution for this problem. That is partly because of
the difficulty in defining the rules as you explain yourself.

Stephen

2008/11/24 James Richardson <[hidden email]>:

>
> Hi,
>
> If i want to calculate, say, simple interest, then I need the number of
> years that the principal has been held, generally as a fractional number.
>
> How can I get Joda Time to give me this fractional number?
>
> Days.daysBetween(x,y) - gives number of days, but cnoverting this to real
> years is different.
>
> Years.yearsBetween(x,y) - gives only whole years.
>
> new Period(x,y) - not sure how this helps me here...
>
> Also, years with leap years would seem to complicate any "naive" solution.
>
> I'm sure this gets done a lot, so any help much appreciated.
>
>
> Thanks!
>
> James
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
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: Fractional Years Difference

Stephen Cresswell
In reply to this post by James Richardson-2
Maybe the TimeAndMoney library has something for this - never used it myself and docs don't seem to be great :(

2008/11/24 James Richardson <[hidden email]>

Hi,

If i want to calculate, say, simple interest, then I need the number of
years that the principal has been held, generally as a fractional number.

How can I get Joda Time to give me this fractional number?

Days.daysBetween(x,y) - gives number of days, but cnoverting this to real
years is different.

Years.yearsBetween(x,y) - gives only whole years.

new Period(x,y) - not sure how this helps me here...

Also, years with leap years would seem to complicate any "naive" solution.

I'm sure this gets done a lot, so any help much appreciated.


Thanks!

James



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...