获取系统当前时间戳
public static void main(String[] args) {
Calendar cal=Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH)+1;
int day = cal.get(Calendar.DATE);
int hour= cal.get(Calendar.HOUR);
int min= cal.get(Calendar.MINUTE);
int sec= cal.get(Calendar.SECOND);
System.out.println(year+"-"+month +"-"+day+" "+hour+":"+min+":"+sec);//获取系统当前时间
}
java Calendar获取当前时间
最新推荐文章于 2024-06-04 14:20:00 发布