Skip to content

Instantly share code, notes, and snippets.

@nurkiewicz
Last active October 24, 2015 16:28
Show Gist options
  • Save nurkiewicz/9d208003cddc57d4273e to your computer and use it in GitHub Desktop.
Save nurkiewicz/9d208003cddc57d4273e to your computer and use it in GitHub Desktop.
import spock.lang.Specification
import spock.lang.Unroll
import java.time.*
@Unroll
class BankSpec extends Specification {
final ZoneId warsaw = ZoneId.of("Europe/Warsaw")
def 'should calculate downtime also in DST'() {
given:
LocalDate date = LocalDate.of(2015, Month.OCTOBER, day)
ZonedDateTime from = ZonedDateTime.of(date, LocalTime.of(2, 30), warsaw)
ZonedDateTime to = ZonedDateTime.of(date, LocalTime.of(3, 30), warsaw)
when:
Duration duration = Duration.between(from, to)
then:
duration == Duration.ofHours(expectedHours)
where:
day | expectedHours
24 | 1
25 | 2
26 | 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment