# Random Date as Feeder

**URL:** <https://community.gatling.io/t/random-date-as-feeder/2637>\
**Category:** Gatling (Open-Source)\
**Created:** [October 23, 2015, 4:19pm UTC](https://community.gatling.io/t/random-date-as-feeder/2637 "2015-10-23T16:19:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CHEN\_YANQING](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@CHEN\_YANQING](https://community.gatling.io/u/CHEN_YANQING)\
**Post date:** [October 23, 2015, 4:19pm UTC](https://community.gatling.io/t/random-date-as-feeder/2637/1 "2015-10-23T16:19:43Z")

</div>

Hello everyone,

Is it possible to generate the current date or timeStamp as Feeder? I need to update the timestamp for each injection…Could anyone help?

Thanks a lot,

Grace

---

<div class="post-metadata">

**Author:** ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)\
**Post date:** [October 23, 2015, 4:51pm UTC](https://community.gatling.io/t/random-date-as-feeder/2637/2 "2015-10-23T16:51:52Z")

</div>

A feeder is one way. Here is another:

`  
import java.util.Date  
import java.text.SimpleDateFormat

object ISO\_TIMESTAMP {  
val isoFormat = “yyyy-MM-dd’T’HH:mm:ssZ”  
def format( d: Date ) =  
new SimpleDateFormat( isoFormat ).format( d )  
override def toString = format( new Date() )  
}

`

To use it, you would save the object into the session, like so:

`  
…exec( session =\> session.set( “CURRENT\_DATE\_TIME”, ISO\_TIMESTAMP ) )

`

Now, every time you reference ${CURRENT\_DATE\_TIME} in an expression, it will always populate with the current date/time.

If you need a date/time that doesn’t automatically update, you can do that easily enough with:

`  
…exec( session =\> session.set( “TRANSACTION\_TIMESTAMP”, ISO\_TIMESTAMP.toString ) )

`

---

<div class="post-metadata">

**Author:** ![CHEN\_YANQING](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@CHEN\_YANQING](https://community.gatling.io/u/CHEN_YANQING)\
**Post date:** [October 26, 2015, 4:00pm UTC](https://community.gatling.io/t/random-date-as-feeder/2637/3 "2015-10-26T16:00:45Z")

</div>

Thanks a lot! It works 😛
