Re: [Joda-interest] Example Code

2010-02-23 Thread David Jarvis
Yes, the logic changed to pay day being two days before the end of the month. ;-) Another real-world example would be to determine if the current day is after the first work-day of the week that is two days before the end of the month. (Microsoft's Excel spreadsheet has a function that can calcula

Re: [Joda-interest] Example Code

2010-02-23 Thread Adam Vartanian
>> And even better as: >> >> public boolean isAfterPayDay(DateTime datetime) { >> >>   return datetime.getDayOfMonth() > datetime.getDaysInMonth() - 2; >> } > > I think you've changed the logic here (in leap years)  :-) Not just in leap years, but also in months with 31 days :) - Adam --

Re: [Joda-interest] Example Code

2010-02-23 Thread Stephen Colebourne
On 22 February 2010 23:57, David Jarvis wrote: > if (datetime.getMonthOfYear() == 2) { // February is month 2!! > > I think it would read better as: > > if( datetime.isMonth( DateTimeConstants.FEBRUARY ) ) { I guess I wanted to emphasise that months were indexed from 1. Your argument is sou

[Joda-interest] Example Code

2010-02-22 Thread David Jarvis
Hi, I have a few suggestions regarding the following code snippet on the front page of Joda-Time: public boolean isAfterPayDay(*DateTime* datetime) { if (datetime.getMonthOfYear() == 2) { // February is mont