Question: How to repeat same task in Handler Thread in specified time delay and update the view in Main thread also.

I need to run this code in background thread repetitively in a interval of 30 seconds and update the result in Main thread as this will block the UI thread if executed here.

```
final Handler handler = new Handler();

    handler.post(new Runnable() {
        @Override
        public void run() {
            int hours = mSeconds/3600;
            int mins = (mSeconds%3600)/60;
            int secs = mSeconds%60;

            String timeElapsed = "";
            if (hours>0){
                timeElapsed = String.format("%02d:%02d",hours,mins);
            }else{
                timeElapsed = String.format("%02d:%02d",mins,secs);
            } 
// there are some other networking stuff also which will be executed here            

            if(mRunning){
                mSeconds++;
            }
// update the view as well

            handler.postDelayed(this, 3000);

        }
    });

```

Answer: 
If the date you are being provided is `[ 2016, 1, 5, 0, 0 ]` this is an array, so we can pull each item out and place it into the `new Date()` method.

See example below:-

```js
d = [ 2016, 1, 5, 0, 0 ];
endDate = new Date(d[0], d[1] - 1, d[2])
console.log(endDate);
```

I am also guessing that the 1 is January, if not, please remove the `- 1` inside the `new Date()` method.

So your code will look like:-

```js
let data = {
  endDate: [2016, 1, 5, 0, 0]
}

data['endDate'] = new Date(data['endDate'][0], data['endDate'][1] - 1, data['endDate'][2])

console.log(data)
```
```
new Date(LocalDateTime) 

```

where LocalDateTime is your local date time