Java获得当前日期和时间的代码
内容摘要
int y,m,d,h,mi,s;
Calendar cal=Calendar.getInstance();
y=cal.get(Calendar.YEAR);
m=cal.get(Calendar.MONTH);
d=cal.get(Calendar.DA
Calendar cal=Calendar.getInstance();
y=cal.get(Calendar.YEAR);
m=cal.get(Calendar.MONTH);
d=cal.get(Calendar.DA
文章正文
int y,m,d,h,mi,s;
Calendar cal=Calendar.getInstance();
y=cal.get(Calendar.YEAR);
m=cal.get(Calendar.MONTH);
d=cal.get(Calendar.DATE);
h=cal.get(Calendar.HOUR_OF_DAY);
mi=cal.get(Calendar.MINUTE);
s=cal.get(Calendar.SECOND);
System.out.println("现在时刻是"+y+"年"+m+"月"+d+"日"+h+"时"+mi+"分"+s+"秒");
代码注释
[!--zhushi--]