score:3

Accepted answer

I was able to do this with a simple for comprehension and the java.time.LocalDate and java.time.Year:

    import java.time.{LocalDate, Year}

    def allDaysForYear(year: String): List[(String, String, String)] = {
      val daysInYear = if(Year.of(year.toInt).isLeap) 366 else 365
      for {
        day <- (1 to daysInYear).toList
        localDate = LocalDate.ofYearDay(year.toInt, day)
        month = localDate.getMonthValue
        dayOfMonth = localDate.getDayOfMonth
      } yield (year, month.toString, dayOfMonth.toString)
    }

score:0

Use Lamma Date

Date(2015, 1, 1) to Date(2015, 12, 131) foreach println 

Date(2015,1,1)
Date(2015,1,2)
Date(2015,1,3)
Date(2015,1,4)

Related Query

More Query from same tag