Well fundamentally you can just add up the "millis since the Unix epoch" of all the `Date`

objects and find the average of those. Now the tricky bit is avoiding overflow. Options are:

- Divide by some known quantity (e.g. 1000) to avoid overflow; this reduces the accuracy by a known amount (in this case to the second) but will fail if you have more than 1000 items
- Divide each millis value by the number of dates you're averaging over; this will always work, but has hard-to-understand accuracy reduction
- Use
`BigInteger`

instead

An example of approach 1:

```
long totalSeconds = 0L;
for (Date date : dates) {
totalSeconds += date.getTime() / 1000L;
}
long averageSeconds = totalSeconds / dates.size();
Date averageDate = new Date(averageSeconds * 1000L);
```

An example of approach 3:

```
BigInteger total = BigInteger.ZERO;
for (Date date : dates) {
total = total.add(BigInteger.valueOf(date.getTime()));
}
BigInteger averageMillis = total.divide(BigInteger.valueOf(dates.size()));
Date averageDate = new Date(averageMillis.longValue());
```

`Date`

objects to milliseconds, take the average, then convert back to a`Date`

object.titlerefers to two dates, but yourquestionrefers to an array of them. There's a significant difference.