Calclulate end of month day

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

Calclulate end of month day

Andreas Rudolf-3
Hi,

how is it possible to calculate the end of a month with respect to a
calendar.

I used something like this:

LocalDate marchEnd = new LocalDate("2008-03-31");
Period monthPeriod = new Period.months(1);
LocalDate febEnd = marchEnd.minus(monthPeriod);   // Results into
29.02.2008
LocalDate janEnd = febEnd.minus(monthPeriod);  // Results into 29.01.2008

I was expecting the 31.1.2008.

How is it possible to decrease by a period of one month and receive
always the correct end of month day?

Regards
Andreas

-------------------------------------------------------------------------
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

andreas_rudolf.vcf (241 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calclulate end of month day

James Carman
Can you go to the first of the following month and then just subtract one day?

2008/8/5 Andreas Rudolf <[hidden email]>:

> Hi,
>
> how is it possible to calculate the end of a month with respect to a
> calendar.
>
> I used something like this:
>
> LocalDate marchEnd = new LocalDate("2008-03-31");
> Period monthPeriod = new Period.months(1);
> LocalDate febEnd = marchEnd.minus(monthPeriod);   // Results into 29.02.2008
> LocalDate janEnd = febEnd.minus(monthPeriod);  // Results into 29.01.2008
>
> I was expecting the 31.1.2008.
>
> How is it possible to decrease by a period of one month and receive always
> the correct end of month day?
>
> Regards
> Andreas
>
> -------------------------------------------------------------------------
> 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: Calclulate end of month day

jodastephen
In reply to this post by Andreas Rudolf-3

date.dayOfMonth().withMaximumValue();

Stephen


Andreas Rudolf wrote:

> Hi,
>
> how is it possible to calculate the end of a month with respect to a
> calendar.
>
> I used something like this:
>
> LocalDate marchEnd = new LocalDate("2008-03-31");
> Period monthPeriod = new Period.months(1);
> LocalDate febEnd = marchEnd.minus(monthPeriod);   // Results into
> 29.02.2008
> LocalDate janEnd = febEnd.minus(monthPeriod);  // Results into 29.01.2008
>
> I was expecting the 31.1.2008.
>
> How is it possible to decrease by a period of one month and receive
> always the correct end of month day?
>
> Regards
> Andreas
>
> -------------------------------------------------------------------------
> 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...