aspose file tools*
The moose likes Java in General and the fly likes Dispalying random dates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Dispalying random dates" Watch "Dispalying random dates" New topic
Author

Dispalying random dates

shalini gnana
Ranch Hand

Joined: Sep 18, 2007
Posts: 189
I want to display the dates between from date to todate...i.e.,if the from date is:2007/01/01 and todate is: 2007/03/01..I want the intermediate date 2007/02/01...I tried to display the dates...But Its not giving me the required(dates between from date and to date)....Its giving some random numbers..



Please help me...

[ November 23, 2007: Message edited by: shalini gnana ]
[ November 23, 2007: Message edited by: shalini gnana ]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20


Just quickly written.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
shalini gnana
Ranch Hand

Joined: Sep 18, 2007
Posts: 189
My question is not that...

I want to display the dates between from date to todate...i.e.,if the from date is:2007/01/01 and todate is: 2007/03/01..I want the intermediate date 2007/02/01...
Oggi Olli
Ranch Hand

Joined: Oct 11, 2007
Posts: 83
Now, I don't know the general practice here at JavaRanch, but why don't you just post the relevant code and the relevant code only?

Anyway, say from date is 2007/01/01 and to date is 2007/01/15. Do you want the intermediate date to be 2007/01/07 or 2007/01/08?
shalini gnana
Ranch Hand

Joined: Sep 18, 2007
Posts: 189
Yes,exactly...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

It's not that different from my earlier code:

shalini gnana
Ranch Hand

Joined: Sep 18, 2007
Posts: 189
Rob,I don't want the date difference or the random date difference...
I want exactly the dates between the start date and the end date....
say, from date is 2007/01/01 and to date is 2007/01/05. I want the intermediate dates, 2007/01/02,2007/01/03,2007/01/04

Can you help me?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

Ah, now I get it. You don't just want the middle date, but all dates in between.

When calculating with dates, always use Calendar instead of Date, since Calendar takes daylight savings time etc into account. If needed, use the add or roll methods, as these also handle new months and years as needed.


Also, "mm" in a date format is the number of minutes. You need "MM" for the month. For performance reasons you will want to declare and initialize that SimpleDateFormat before the loop, not inside.
[ November 23, 2007: Message edited by: Rob Prime ]
shalini gnana
Ranch Hand

Joined: Sep 18, 2007
Posts: 189
Thanks alot for your help..Now,I could able to display..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dispalying random dates