import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
public class panduan {
public static void main(String[] args) {
Date date1 = new Date();
long d1=date1.getTime();
System.out.println("毫秒时间戳 "+d1);//获取13位时间戳-毫秒
LocalDate date2 = LocalDate.now();
System.out.println("当前系统日期 "+date2);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
String d11=sdf.format(d1);
System.out.println(sdf.format(d1));
if(date2.toString().equals(d11)){
System.out.println("ok");
}else {
System.out.println("!!ok");
}
}
/**
* 获取当前系统时间 并指定格式
* @param time 时间毫秒戳
* @return
*/
public static String timeToFormat(long time) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
System.out.println(sdf.format(time));
return sdf.format(time);
}
}