unixtime

Getting “unixtime” in Java

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Date.getTime() returns milliseconds since Jan 1, 1970. Unixtime is seconds since Jan 1, 1970. I don't usually code in java, but I'm working on some bug fixes. I have: Date now = new Date(); Long longTime = new Long(now.getTime()/1000); return longTime.intValue(); Is there a better way to get unixtime in java? UPDATE Based on John M's suggestion, I ended up with: return (int) (System.currentTimeMillis() / 1000L); 回答1: Avoid the Date object creation w/ System.currentTimeMillis() . A divide by 1000 gets you to Unix epoch. As mentioned in a

mysql 一些知识点

强颜欢笑 提交于 2019-11-28 18:17:19
常用的实用sql语句: 1.example: SELECT *,FROM_UNIXTIME(f_create_time/1000,'%Y-%m-%d %H:%i:%s') date from report.t_org_exam_num_day ORDER BY date desc FROM_UNIXTIME()把毫秒级别的时间转换为年月日,时分秒格式的 来源: https://www.cnblogs.com/lipengsheng-javaweb/p/11419209.html