Java获取当前系统事件System.currentTimeMillis()方法

网友投稿 292 2023-05-11


Java获取当前系统事件System.currentTimeMillis()方法

System.currenSojbItBXtTimeMillis()产生一个当前的毫秒,这个毫秒其实就是自1970年1月1日0时起的毫秒数,Date()其实就是相当于Date(System.currhttp://entTimeMillis()),因为Date类还有构造Date(longdate),用来计算long秒与1970年1月1日之间的毫秒差。

得到了这个毫秒数,我们自己也可以算起现在的年月日周时,但是这不是我们去计算的,因为有Calendar.Calendar最终结出的结果就是年月日周时时区。

System.currentTimeMillis()获得的是自1970-01-01 00:00:00.000到当前时刻的时间距离,类型为long

String.valueOf(System.currentTimeMillis())这个语句可转为一下的格式:

long ct = System.currentTimeMillis();

String t = String.valueOf(ct);

其实上面的String t就相当于 ct+"";

知识转为字符串格式

public String refFormatNowDate(){

Date nowTime = new Date(System.currentTimeMillis());

SimpleDateFormat sdFormatter = new SimpleDateFormat("yyy-MM-dd");

String retStrFormatNowDate = sdFormatter.format(nowTime);

return retStrFormatNowDate;

}


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:SpringMVC+bootstrap table实例详解
下一篇:解决BootStrap Fileinput手机图片上传显示旋转问题
相关文章

 发表评论

暂时没有评论,来抢沙发吧~