代码如下

import java.text.SimpleDateFormat
import java.util.Calendar

object yesterday {
    def main(args: Array[String]) = {
        val ymdFormat = new SimpleDateFormat("yyyyMMdd")
        val day:Calendar = Calendar.getInstance()
        day.add(Calendar.DATE, -1)
        val logDate = ymdFormat.format(day.getTime)
        println("logDate:\t"+logDate)
    }
}