# Problem with Date() constructor inside each block

**URL:** <https://discuss.elastic.co/t/problem-with-date-constructor-inside-each-block/35117>\
**Category:** Elasticsearch\
**Created:** [November 20, 2015, 3:31am UTC](https://discuss.elastic.co/t/problem-with-date-constructor-inside-each-block/35117 "2015-11-20T03:31:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luiz\_Zamboni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luiz_zamboni/32/4324_2.png) [@Luiz\_Zamboni](https://discuss.elastic.co/u/Luiz_Zamboni)\
**Post date:** [November 20, 2015, 3:31am UTC](https://discuss.elastic.co/t/problem-with-date-constructor-inside-each-block/35117/1 "2015-11-20T03:31:45Z")

</div>

Strange error when execute follow script

```
valid_concurrents = _source.concurrents.findAll{ concurrent_ids.contains(it.seller_id) };

def with_data = [];
valid_concurrents.each{
	d = [:];
	d["id"] = it.id;
	d["seller_id"] = it.seller_ida;
	d["name"] = it.name;
	d["diff_price"] = _source.new_price - it.new_price;
 	d["diff_percent"] = (_source.new_price / it.new_price * 100) - 100; 
 	if(_source.new_price == it.new_price){
 		d["status"] = "equal";
 	}else if(_source.new_price > it.new_price){
 		d["status"] = "winning";
 	}else if(_source.new_price < it.new_price){
 		d["status"] = "losing";
 	};
	d["crawled_at_seconds"] = ((new Date().time - new Date(it["updated_at"].value).time)/1000).toInteger();
	with_data << d;
};

```

return with\_data;

## Could not find matching constructor for: java.util.Date([C)]

Why the "((new Date().time - new Date(it["updated\_at"].value).time)/1000).toInteger();" not works inside each block outsite it works...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:37pm UTC](https://discuss.elastic.co/t/problem-with-date-constructor-inside-each-block/35117/2 "2017-07-05T23:37:05Z")

</div>

Closed on July 5, 2017, 11:37pm UTC


