• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Get Dates between the given dates.

 
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this: one of the simpler ways -


[ May 29, 2006: Message edited by: Mandar Max ]
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic