如何让我的 Java 应用程序从某个在线时钟获取全球时间 [英] how to make my java app get global time from some online clock
本文介绍了如何让我的 Java 应用程序从某个在线时钟获取全球时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作一个分布式 Java 应用程序,我需要应用程序的两个部分都在一个标准时间运行.由于系统时间可能不同,我在想 Java API 是否包含一些类可以从标准的在线源下载时间?
I am making a distributed java app for which I need both parts of the app to run on one standard time. Since system times can be different I was thinking if java API contains some class to download time from a standard online source?
推荐答案
您需要使用NTP(网络时间协议):
You need to use the NTP (Network Time Protocol):
http://en.wikipedia.org/wiki/Network_Time_Protocol
以下链接包含一些用于与 NTP 服务器交互的参考 Java NTP 客户端代码:
The following link contains some reference Java NTP Client code for interacting with an NTP server:
http://psp2.ntp.org/bin/view/Support/JavaSntpClient
这篇关于如何让我的 Java 应用程序从某个在线时钟获取全球时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文