标签:system format 时间 str second class java cond date
Date用法
Date datetime = new Date();
//获取当前日期
String date = String.format("%tF", datetime);
System.out.println(date); // 2020-03-08
// 获取当前时间
String time = String.format("%tT", datetime);
System.out.println(time); // 18:22:40
// 获取1970-01-01 00:00:00到当前的秒数
String second = String.format("%ts", datetime);
System.out.println(second); // 1583663377
// 获取从1970-01-01 00:00:00到当前的毫秒
String miSecond = String.format("%tQ",datetime);
System.out.println(miSecond); // 1583663518832
标签:system format 时间 str second class java cond date
原文地址:https://www.cnblogs.com/lin3615/p/12444132.html