电子说
import java.sql.Timestamp; //导包
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
System.out.println(nowTime);
输出:
2022-06-08 11:15:51.014
Long timeLong = System.currentTimeMillis();
System.out.println("timeString:" + timeLong + "\\n");
输出:
1652862076686
Long timeLong = System.currentTimeMillis();
SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置格式
String timeString = timeFormat.format(timeLong);
System.out.println("timeString:" + timeString + "\\n");
输出:
2022-06-08 11:15:51
审核编辑 黄昊
全部0条评论
快来发表一下你的评论吧 !