Skip to content

Instantly share code, notes, and snippets.

@gonaumov
Created January 29, 2020 10:04
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 gonaumov/6c9816cc251c2fec73234b585e2986b8 to your computer and use it in GitHub Desktop.
Save gonaumov/6c9816cc251c2fec73234b585e2986b8 to your computer and use it in GitHub Desktop.
val calculatedTimezoneOffset = TimeZone.getDefault().let {
// The problem is
// TimeZone.getTimeZone("UK").inDaylightTime(Date())
// is false every time. If this is true everything pass.
val offset = if(TimeZone.getTimeZone("UK").inDaylightTime(Date()))
it.getOffset(System.currentTimeMillis()) + 3600000 // -> this is the one hour of daily saving time.
else
it.getOffset(System.currentTimeMillis())
offset
}
assertThat(never.created.time + calculatedTimezoneOffset).isEqualTo(formatter.parse("2019-08-23 15:50:00").time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment