大家好,又见面了,我是你们的朋友全栈君。
获取系统当前时间戳
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);//获取系统当前时间
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/133345.html原文链接:https://javaforall.cn