0

I have such 2 variables:

val dateFrom = "2018-01-15"
val dateTo = "2018-06-15"

How to make such string which has all days between 2 date:

{20180115,20180116,...,20180614,20180615}

P.S. As you can see format of date in final result is "yyyyMMdd".

Thats what I try right now:

import org.joda.time.{DateTime, Days}

def getDaysInBetween(from: DateTime, to: DateTime): Int = Days.daysBetween(from, to).getDays

def getDatesInBetween(from: DateTime, to: DateTime): Seq[DateTime] = {
  val days = getDaysInBetween(from, to)
  (0 to days).map(day => from.plusDays(day))
}

getDatesInBetween function return collection of date in DateTime format.

Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193

0 Answers0