| Author |
Get Dates between the given dates.
|
MInu
Ranch Hand
Joined: Oct 09, 2003
Posts: 517
|
|
Hi, i am trying to do someting like this: A user choose a initial and a final date. For example: Ini: 07/07/2004 Fin: 11/07/2004 Ok, what i need to do, is to get all dates between this two above. The answer needs to be... 08/07/2004 09/07/2004 10/07/2004 Is there a method that do this for me, i ve looking for but not finding ? Thanks...
|
God Gave Me Nothing I Wanted<br />He Gave Me Everything I Needed<br /> - Swami Vivekananda
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
There is no method, but it should be easy enough. Have a look at the Calendar class and in particular its add(int field, int amount) method. [ May 25, 2006: Message edited by: Paul Sturrock ]
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Jean-Francois Briere
Ranch Hand
Joined: Mar 03, 2004
Posts: 101
|
|
Also to convert the string "07/07/2004" into a java.util.Date object (or the reverse) have a look at the java.text.SimpleDateFormat class. Regards
|
 |
Mandar Max
Ranch Hand
Joined: Mar 14, 2006
Posts: 38
|
|
Try this: one of the simpler ways - [ May 29, 2006: Message edited by: Mandar Max ]
|
"The trouble with doing something right the first time is that nobody appreciates how difficult it was!"
|
 |
Ravindra Rawat
Ranch Hand
Joined: Dec 09, 2004
Posts: 34
|
|
Check the time component of dates that your have generated if that is used in your application. If your date range has has dates when daylight saving is turned on or off then time component changes while you increment date using calendar API, e.g 24:00 in your code may change to 23:00 or 01:00. Cheers Ravindra
|
 |
Jan Groth
Ranch Hand
Joined: Feb 03, 2004
Posts: 456
|
|
hi, i had almost the same problem and solved it quite comfortably with the joda-time framework. just google for it, it's a sourceforge project. these guys did a great job, specially when it comes to daylight saving time and leap-years... hope it helps, greetings from world-cup crazy berlin, jan
|
 |
 |
|
|
subject: Get Dates between the given dates.
|
|
|