Skip to content

Instantly share code, notes, and snippets.

@leonardoxh
Last active May 29, 2019 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonardoxh/c8d2757cd3acc9874936f1d4bdb69153 to your computer and use it in GitHub Desktop.
Save leonardoxh/c8d2757cd3acc9874936f1d4bdb69153 to your computer and use it in GitHub Desktop.
Simple timezone calculations
import java.util.Date
import java.uti.TimeZone
/** Local date to UTC */
val Date.utc: Date get() = Date(time + TimeZone.getDefault().rawOffset)
/** UTC date to local date */
val Date.local: Date get() = Date(time - TimeZone.getDefault().rawOffset)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment