package Test4
import java.text.SimpleDateFormat
import java.util.Date
import org.joda.time.DateTime
object Test4{
def main(args: Array[String]): Unit ={
val time ="2020-10-31T08:04:34+08:00"
val sdf =newSimpleDateFormat("yyyy-MM-dd HH:mm:ss")// org.joda.time.DateTime类
val date =newDateTime(time).toDate
val dt = sdf.format(date)
val tempTime: Long = sdf.parse(dt).getTime
println(tempTime)println(sdf.format(newDate(tempTime)))}}
方法一(推荐)package Test4import java.text.SimpleDateFormatimport java.util.Dateimport org.joda.time.DateTimeobject Test4{ def main(args: Array[String]): Unit = { val time = "2020-10-31T08:04:34+08:00" val sdf = new SimpleDateForma