Question: I am developing an app that loops for several hours or even maybe days and what I want is that it loops past the current day into the next it creates a new file with a new file name.
Can anyone help me with the logic ?
Here is my code:

```
    timedata= new File(timedata)
    String timedatafile=  "/sdcard/timedata"+"-"+formattedDate+".csv";

    if(MsureData.exists()!=true)
{
    timedata.createNewFile();
    Calendar c = Calendar.getInstance();
    String formattedDate = df.format(c.getTime()); 
    // do stuff
}

```

Answer: 
You may use [Quartz API](http://www.quartz-scheduler.org/) to schedule a job to be executed at a specific time. See these tutorials-<http://www.mkyong.com/java/quartz-scheduler-example/>
```
Date currentDate = new Date(System.currentTimeMillis());

```

From this you can get current date of system.