Parse Time stamp

Sorry for the simple question… How do i parse a timestamp in JSON to a display of a nice date time? I’m not familiar with it.

The timestamp would be


2/16/2016 02:05 PM

or something like that.

It’s in Unix “Epoch” format… Lots of available methods to convert, many provided on this helpful site:

What would the code be in a groovy app?

I believe that most of the Java methods will work.

See the lower portion of the linked page…

I’m getting an

Error: java.lang.IllegalArgumentException: Cannot format given Object as a Date

Do i need to convert it to a Int or something?

Yeah, i used the java methods and tried… no luck. When i put the value in the epoch converter it shows the right date time. But nothing inside of the groovy app.

def timeString = new Date(unixTS+ location.timeZone.rawOffset ).format(“yyyy-MM-dd HH:mm”)
That would convert from UTC to your hubs current time zone.
If you just want the conversion, drop the location offset


Thanks Mike, that was what I need. I appreciate it.

1 Like