如何获得当前午夜以来的毫秒数? [英] How can I get the count of milliseconds since midnight for the current?

查看:200
本文介绍了如何获得当前午夜以来的毫秒数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意,我不希望毫米来自时代。我想要当前时钟的毫秒数。

Note, I do NOT want millis from epoch. I want the number of milliseconds currently on the clock.

例如,我有这段代码。

Date date2 = new Date(); 
Long time2 = (long) (((((date2.getHours() * 60) + date2.getMinutes())* 60 ) + date2.getSeconds()) * 1000);

有没有办法获得日期的毫秒数?
还有另外一种方法吗?

Is there a way to get milliseconds with date? Is there another way to do this?

注意: System.currentTimeMillis()给了我来自时代的毫秒,这不是我想要的。

Note: System.currentTimeMillis() gives me millis from epoch which is not what I'm looking for.

推荐答案

你的意思是?

long millis = System.currentTimeMillis() % 1000;






BTW Windows不允许timetravel到1969


BTW Windows doesn't allow timetravel to 1969

C:\> date
Enter the new date: (dd-mm-yy) 2/8/1969
The system cannot accept the date entered.

这篇关于如何获得当前午夜以来的毫秒数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆