這個特別簡單,只需一行代碼:
Date d =newDate(時間值);
SimpleDateFormat sdf =newSimpleDateFormat("yyyy-MM-dd? hh:mm:ss");
sdf.format(d)
哈哈,簡單吧!
下面是把時間轉化為毫秒數
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmm");
long millionSeconds = sdf.parse(str).getTime();//毫秒
獲取當前的時間點
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//設置日期格式
long millionSeconds = sdf.parse(str).getTime();//毫秒