score:1

Accepted answer

First, it's a good idea to create a case class to represent period of time

case class Period(start: Date, end: Date)

So, declare constants like that :

val period1 = Period(d1, d2)
val period2 = Period(d3, d4)

And create a sequence and iterate over with a for comprehension

for (d <- Seq(period1, period2)) yield {…}

Related Query

More Query from same tag