import java.text.SimpleDateFormat
import java.util.Date
object 日期工具类 {
object DateUtils {
var sdf: SimpleDateFormat = null
def date2String(date: Date, template: String): String = {
sdf = new SimpleDateFormat(template)
sdf.format(date)
}
def string2Date(dateStr: String, template: String): Date = {
sdf = new SimpleDateFormat(template)
sdf.parse(dateStr)
}
}
def main(args: Array[String]): Unit = {
println(DateUtils.date2String(
new Date(), "yyyy年MM月dd日 HH:mm:ss"))
println(DateUtils.string2Date(
"1314年11月11日", "yyyy年MM月dd日"))
}
}