更新時間:2022-04-21 11:18:59 來源:動力節點 瀏覽1245次
有些小伙伴對Java格式化日期還不是很了解,動力節點小編用以下實例演示了如何使用 SimpleDateFormat 類的 format(date) 方法來格式化時間
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main{
public static void main(String[] args){
Date date = new Date();
String strDateFormat = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
System.out.println(sdf.format(date));
}
}
以上代碼運行輸出結果為:
2015-03-27 21:13:23
0基礎 0學費 15天面授
有基礎 直達就業
業余時間 高薪轉行
工作1~3年,加薪神器
工作3~5年,晉升架構
提交申請后,顧問老師會電話與您溝通安排學習