Created
January 29, 2020 10:04
-
-
Save gonaumov/6c9816cc251c2fec73234b585e2986b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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