• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generating a Start and Finish Date  RSS feed

 
Steve Dyke
Ranch Hand
Posts: 1780
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my date generation code:



This is my result which is generation unfavorable finish dates:

SystemOut O Thu May 01 16:14:33 CDT 2008, Sat May 31 16:14:33 CDT 2008
SystemOut O Sun Jun 01 16:14:33 CDT 2008, Mon Jun 30 16:14:33 CDT 2008
SystemOut O Tue Jul 01 16:14:33 CDT 2008, Wed Jul 30 16:14:33 CDT 2008
SystemOut O Fri Aug 01 16:14:33 CDT 2008, Sat Aug 30 16:14:33 CDT 2008
SystemOut O Mon Sep 01 16:14:33 CDT 2008, Tue Sep 30 16:14:33 CDT 2008
SystemOut O Wed Oct 01 16:14:33 CDT 2008, Thu Oct 30 16:14:33 CST 2008
 
Stevi Deter
Ranch Hand
Posts: 265
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve,

I think your question is, why doesn't adding a month to the end date automatically set it to the end of the month.

I think you should try to use the same solution you're using to find the last day of the month when you initialize fcal, and you'll find that gets the results (I think) you're looking for.
 
Steve Dyke
Ranch Hand
Posts: 1780
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried using:

fcal.set(Calendar.DAY_OF_MONTH, scal.getActualMaximum(Calendar.DATE));

in my second situation but the finish date results were either 05/30/2008 or 05/31/2008 for my 12 finish dates.

What can I use besides (Calendar.DATE) for the second situation?
 
Stevi Deter
Ranch Hand
Posts: 265
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve,

You still have to up the month. The following gave me the results expected (always last day of current month):

 
Steve Dyke
Ranch Hand
Posts: 1780
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, works great now.
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you know, this thread is kinda confusing, with two Steve D's
 
Stevi Deter
Ranch Hand
Posts: 265
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nah, there's a Steve D. and a Stevi D.

I suspect the first is pronounced with one syllable and the second with two.
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well your names still look similar enough for me to get confused for a sec. I was starting to wonder why Steve was replying to himself all the time
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!