Bookmark Topic Watch Topic
  • New Topic

Java Calendar Dates  RSS feed

 
Anil Karamchandan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi all,

I am currently building a payroll software code and stuck at a point, I would do my best to explain and get any help

I have a pay period Start date and End Date this can be any period

When I enter the period as (in mm/dd/yyyy format)

Start date "04/08/2010"
End Date "05/08/2010"

then I add 1 month to a calendar handler.add(Calendar.Month,1)

the next and the corresponding dates are

Start date "05/08/2010"
End Date "06/08/2010"

Start date "06/08/2010"
End Date "07/08/2010"

corresponding as desired. But the moment I enter the start date and end date as
as

Start date "04/01/2010"
End Date "04/30/2010" which is a 1 Month period and then add 1 Month to the code
the corresponding dates are

Start date "05/01/2010"
End Date "05/30/2010"

Start date "06/01/2010"
End Date "06/30/2010" [ Even though it has 31 days in June, then from Feb 2011 its like


Start date 01/01/2011
End Date 01/30/2011

Start date 02/01/2011
End date 02/28/2011

Start date 03/01/2011
Start date 03/28/2011

everything ends on the 28th

Can any one let me know why in my first condition the 31st day was being taken care of and in the next condition I am not getting the same output.


Details 04/01/2011 04/28/2011


 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place. Please read this for more information.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!