在scala中时间是使用java的 Calendar 下面是实例代码
import java.text.SimpleDateFormat import java.util.Calendar /** * Created by ZQ on 2015/7/16. */ object Test { def main(args: Array[String]) { val today = Calendar.getInstance().getTime() //12小时制 val date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") // create the date/time formatters val minuteFormat = new SimpleDateFormat("mm") val hourFormat = new SimpleDateFormat("hh") val amPmFormat = new SimpleDateFormat("a") val currentHour = hourFormat.format(today) // 12 val currentMinute = minuteFormat.format(today) // 29 val amOrPm = amPmFormat.format(today) println("currentHour="+currentHour) println("currentMinute="+currentMinute) println("amOrPm="+amOrPm) println("date="+date.format(today)) } }