Parse date before sending an httpPostJson


(JohnD) #1

I have a smartapp that sends an HttpPostJson everytime an event occurs, The following is the contents of the post.

{u’temp’: 70, u’Type’: u’motion’, u’id’: u’184c0a6c-b435-4a7e-bb56-29e233c8f7db’, u’value’: u’inactive’, u’time’: {u’seconds’: 28, u’year’: 114, u’month’: 9, u’hours’: 14, u’time’: 1413298048380, u’date’: 14, u’minutes’: 47, u’day’: 2, u’timezoneOffset’: 0}}

This is my smartapps function that does the post

def contactHandler(evt) {
	log.debug "$evt.value"
     httpPostJson(uri: "serverIP", body: [id: evt.deviceId, Type: evt.name, 
                   value: evt.value, time: evt.date, temp: contact1.currentTemperature])
                   {response ->
        log.debug response.data
    }
}

What can I do to convert the time/date to “DD/MM/YYYY HH:MM:SS” format before I send it to my server?.

Thanks