TimeZone.setDefault() -> Security Exception -?

Hi All,

Just received this mail from ST:

Dear Valued Customer,

We are writing to inform you of a change we are making to the SmartThings platform that impacts one or more of your SmartApps or Device Type Handlers. Beginning very shortly (most likely by or shortly after the time you read this), we are going to be restricting the “setDefault”, method on the TimeZone class. We have identified you as
having a SmartApp or Device Type that use this method, and wanted to reach out to you directly to let you know that this will now throw a “Security Exception”.

An example of this would be using the following: “TimeZone.setDefault()”.

Anyone have any information on this issue? Pointer to docs/discussion? Thanks,

Doug

I think I’ve found the offending code snippet:

TimeZone.setDefault(TimeZone.getTimeZone(“US/Eastern”))
def now = new Date()
def hour = now.getHours()
if (hour >= 6) {…

Looks like I was just trying to determine if the current time (the time of the event) was after 6AM EST. Is there a better/standard way of doing that?

Thanks,

Doug

hour = new Date().format(“H”, location.timeZone)

location.timeZone -> pulls the timezone settings from the hub

3 Likes

discussion about this change…
http://docs.smartthings.com/en/latest/getting-started/groovy-for-smartthings.html#allowed-classes

2 Likes

Thank you, I very much appreciate the code snippet.