且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 JAVA 中将纪元转换为 mySQL 时间戳

更新时间:2023-01-23 08:35:45

为什么不一直使用普通的Date?

Why not use a normal Date all along?

Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_MONTH, -7);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
String output = formatter.format(cal.getTime());