Question: am writing a program in java on Linked List. I get an error when i use toString to return the IP address and PC of the code below.

```
package linked;

import java.net.InetAddress;

public class Work {
    private InetAddress IP;
    private String PC;

    public Work(InetAddress IP, String PC){
        this.IP=IP;
        this.PC=PC;
    } 
    public InetAddress getIP(){
        return IP;
    }
    public String getPC(){
        return PC;
    }
    @Override
    public String toString() {
        return IP + ' ' + PC;
    }
}

```

It comes up with an error in the `@Override` that says 

> 
> bad operand types for binary operator '+' first type: InetAddress  
> 
>  second type: char
> 
> 
>

Answer: 
You can use [moment.isAfter](https://momentjs.com/docs/#/query/is-after/) and [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) to clean the old dates and the `null` values.

```js
const dates = [
  "2018-04-02T15:15",
  "2018-04-07T14:20",
  "2018-04-28T11:50",
  null,
  null,
  null,
  null,
  "2018-05-30T17:45",
  "2018-04-07T16:20"
]

const futureDates = dates.filter(date => moment(date).isAfter())

console.log(futureDates);
```

```html
<script src="https://momentjs.com/downloads/moment.js"></script>
```

> 
> How do I get the count of just future dates?
> 
> 
> 

After using filter, only the valid dates remain, so:

```
console.log(futureDates.length);

```
Use [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) like below if don't consider the situations like time zone, invalid date string etc:

```js
const test = [
  "2018-04-02T15:15",
  "2018-04-07T14:20",
  "2018-04-28T11:50",
  null,
  null,
  null,
  null,
  "2018-05-30T17:45",
  "2018-04-07T16:20"
]
const currentWhenCalc = new Date()
result = test.filter(function(item){
  return item && new Date(item) > currentWhenCalc
})
console.log('data', result, 'count', result.length)
```