import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public void test2() throws ParseException {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date date = df.parse("2021-01-01");
Calendar cal = Calendar.getInstance();
cal.setTime(date);
long timestamp = cal.getTimeInMillis();
System.out.println(timestamp);
System.out.println(timestamp/1000);
}
//1609430400000
//1609430400
13位的时间戳,其精度是毫秒(ms);
10位的时间戳,其精度是秒(s);
13位数的时间戳转化为10位数的时间戳 ,除以1000;
10位数的时间戳转化为13位数的时间戳 ,乘以1000;
//获得当前时间的时间戳,单位是毫秒
//new Date().getTime()