The accepted Answer is correct.
As of Java 8 and later, the java.util.Date/.Calendar classes are now outmoded.
java.time
The java.time framework built into Java 8 and later supplants the troublesome old java.util.Date/.Calendar classes. The new classes are inspired by the highly successful Joda-Time framework, intended as its successor, similar in concept but re-architected. Defined by JSR 310. Extended by the ThreeTen-Extra project. See the Tutorial.
First we define a formatter using a pattern to match our expected input String.
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
The java.time framework includes a class to represent a date-only value, without time-of-day: LocalDate. A static method on that class can parse.
String input = "05/07/2013";
LocalDate localDate_Start = LocalDate.parse( input , formatter );
If the user gives us bad text input, the parse method throws a DateTimeParseException. So we should catch and handle that exception.
try{
LocalDate localDate_Start = LocalDate.parse( input , formatter );
} catch ( DateTimeParseException e ) {
// … handle the exception …
}
The LocalDate class includes a plusDays method to add days.
LocalDate localDate_Stop = localDate_Start.plusDays( someNumberOfDays );
By the way, in date-time work we commonly use the Half-Open approach where the beginning is inclusive while the ending is exclusive. For example a week would run from a Monday up to, but not including, the following Monday.
A while loop makes more sense to me than your use of a for loop
To do some database work we must convert from java.time.LocalDate to java.sql.Date. Someday JDBC drivers will be updated to directly handle java.time types but until then we must covert. Look for newly added conversion methods such as java.sql.Date.valueOf( LocalDate localDate ).
LocalDate localDate = localDate_Start;
while( localDate.isBefore( localDate_Stop ) ) {
// Do some database work.
// Until JDBC drivers updated to handle java.time types, convert to java.sql type.
java.sql.Date sqlDate = java.sql.Date.valueOf( localDate );
// … do you database work.
// Prepare for next iteration of this 'while' loop.
localDate = localDate.plusDays( 1 );
}
initDate = addDays(initDate, 1)??