获取当前时间及时间戳方法


获取UUID:
System.out.println("UUID:"+UUID.randomUUID().toString());
获取时间戳方法:
System.out.println("时间戳:"+Calendar.getInstance().getTimeInMillis());
System.out.println("时间戳:"+System.currentTimeMillis());
System.out.println("时间戳:"+new Date().getTime());
格式化到毫秒:
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
System.out.println(sdf.format(new Date()));

控制台输出结果:

时间戳在线测试地址:http://tool.chinaz.com/Tools/unixtime.aspx

相关博客:https://blog.csdn.net/zhangzehai2234/article/details/53365633




					


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM