How do I get dates between two dates?

In the following example code I am going to get  dates between two dates. First, I need to convert the date value into milliseconds and increase startup date value from one date.

One date in milliseconds equlas to 24 * 60 * 60 * 1000L

import java.util.*;

public class DateUtil {
 static final long ONE_DAY = 24 * 60 * 60 * 1000L;

 public static void main(String[] args) {


 public static void getDatesBetween(String startDate,String endDate) {

        long  from=Date.parse(startDate);  // long value of from date

        long to=Date.parse(endDate);     // long value of to date

        int x=0;

        while(from <= to) {
              System.out.println ("Dates  : "+new Date(from));
              from += ONE_DAY;
        System.out.println ("No of Dates  :"+ x);




Popular posts from this blog

XSLT - Modify Date and DateTime value

Integrate With Mutual Certificate Authentication based Service

Yield Price Sri Lanka - Android Application