Avatar of kpbarem
kpbarem
 asked on

How to create an array of dates between two given Date objects

I have two Date objects in Java (Java.util.Date) that are being passed in to a method I am writing.  I was thinking this would be fairly simple, but I can't think of a straight forward way to do this.  I want to first figure out which date is greater and then figure out the difference between the two in days.  Then I simply want to use a loop to create code that is something along the lines.. of

for (int i = o; i < distance between two dates in days; i++){
Date d = new Date("low date + i days");
dateList.add(d);
}
Date[] dateArray = dateList.ToArray();

I'm not entirely sure how to do this, since i'm not entirely sure how to get the distance between the dates in Days.  I'm also not sure if this is the best method to sue to go about this.  Can anyone help me out?

Thanks
JavaJava EEProgramming

Avatar of undefined
Last Comment
kpbarem

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
kaufmed

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
CEHJ

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
kpbarem

ASKER
I ended up going with the first one but I saw no reason why the second one wouldn't work.

Thank you!!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23