重新格式化日期时间数组

reformat DateTime Array

我使用 jodatime

使用以下代码生成了一个日期数组
import org.joda.time.{DateTime, Period}
import org.joda.time.format.DateTimeFormat
import java.text.SimpleDateFormat


def dateRange(from: DateTime, to: DateTime, step: Period): Iterator[DateTime] 
=Iterator.iterate(from)(_.plus(step)).takeWhile(!_.isAfter(to))

val from = new DateTime(2000, 06, 30,0,0,0,0)
val to = new DateTime(2001, 06, 30,0,0,0,0)
val by = new Period(0,2,0,0,0,0,0,0)

val range = { dateRange(from ,to, by)}

val dateRaw = (range).toArray

如何将 DateTimeFormat.forPattern("YYYYMMdd") 传递给每个值以获得格式为 yyyyMMdd

的整数数组

数组[Int] = 数组(20000630,20000830,20001030...

val f = DateTimeFormat.forPattern("YYYYMMdd")
dateRaw.map(d => f.print(d).toInt)