如何在Java中确保当前的本地时间是正确的? [英] How can I ensure in Java that the current local time is correct?

查看:147
本文介绍了如何在Java中确保当前的本地时间是正确的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要确保在我的客户端应用程序中用户不会显着改变计算机日期(例如,将其提前一个月)。



到据我所知,检查Java当前时间的最佳方法是

  System.currentTimeInMillis()

如何在多平台环境(Windows,Linux,Mac等)中确保这是正确的日期。 )?



没有连接到可用的远程服务器,也没有连接到互联网。此外,在启动时,时间可能已经被篡改。我只需要检查内部业务逻辑目的的时间,而不是设置任何东西。

解决方案

无线电时钟



获取



Sundial



在外面定位



黑盒子,无输入=不开始



更严重的是,如果你不信任系统时间,你无法访问时间服务器,你无法询问用户当前时间,我无法想象任何解决方案。您有一个没有输入的黑匣子。通过USB的无线电时钟正在添加这样的输入。



维基百科上有一篇关于时钟同步


I need to make sure that in my client application the user doesn't dramatically change the machine date (e.g. bringing it to 1 month before).

To the best of my knowledge, the best way to check the current time in Java is

System.currentTimeInMillis()

How can I make sure that this is the correct date, in a multiplatform environment (either Windows, Linux, Mac, etc.)?

No connection to remote servers available, nor to the internet. Also, at startup time the time could be already tampered. I just need to check the time for internal biz logic purpose, not to set anything.

解决方案

Radio Clock

Obtain a radio clock with a USB connection for output of current time synchronized by a time code transmitted by a radio transmitter connected to a time standard such as an atomic clock. Similarly, a receiver of GPS signals could also capture the time signal.

The Meinberg Global company, at least, offers several such devices.

Sundial

Position a sundial outside a window. Attach a webcam to the computer in question. Position the webcam in the window. Write an app to interpret the time of day from current image of the sundial.

Black Box, No Inputs = No Go

More seriously, if you do not trust the system time, you have no access to a time server, and you cannot ask the user for current time, I cannot imagine any solution. You have a black box with no inputs. The radio clock via USB is adding such an input.

Wikipedia has an article on Clock synchronization.

这篇关于如何在Java中确保当前的本地时间是正确的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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