当前位置:网站首页>ntp服务器 时间(查看服务器时间)
ntp服务器 时间(查看服务器时间)
2022-07-28 18:53:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
public static String getNTPServerDateTime(String NTPTimeServerUrl) {
String dateTimeMessage;
try {
NTPUDPClient timeClient = new NTPUDPClient();
InetAddress timeServerAddress = InetAddress.getByName(NTPTimeServerUrl);
TimeInfo timeInfo = timeClient.getTime(timeServerAddress);
TimeStamp timeStamp = timeInfo.getMessage().getTransmitTimeStamp();
Date date = timeStamp.getDate();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
dateTimeMessage = dateFormat.format(date);
} catch (UnknownHostException e) {
return e.getMessage();
} catch (IOException e) {
return e.getMessage();
}
return dateTimeMessage;
}NTPTimeServerUrl为NTP服务器地址,如上海交通大学网络中心NTP服务器地址为:202.120.2.101 边栏推荐
- Explain the life cycle function in unity in detail
- 不懂就问,快速成为容器服务进阶玩家!
- What is data center? What value does the data center bring_ Light spot technology
- C # basic 7-iterator and coroutine
- Unity gadget displays the file size of the resource directory
- Three deletion strategies and eviction algorithm of redis
- "When you are no longer a programmer, many things will get out of control" -- talk to SUSE CTO, the world's largest independent open source company
- 一文读懂Okaleido Tiger近期动态,挖掘背后价值与潜力
- Unity object path query tool
- [server data recovery] HP StorageWorks series storage RAID5 two disk failure offline data recovery case
猜你喜欢

prometheus配置alertmanager完整过程

Explain various coordinate systems in unity in detail

LVS+KeepAlived高可用部署实战应用

激光slam:LeGO-LOAM---代码编译安装与gazebo测试

Three steps to teach you unity serial communication

Unity object path query tool

The engineering practice of super large model was polished, and Baidu AI Cloud released the cloud native AI 2.0 solution

JS drag and drop alert pop-up plug-in

想画一张版权属于你的图吗?AI作画,你也可以

Job CE
随机推荐
Sorting out problems in interface endpoint testing practice using Supertest
How can enterprises successfully complete cloud migration?
Oracle库访问很慢,是什么原因?
C # basic 4-written examination question 1
leetcode:2141. 同时运行 N 台电脑的最长时间【最值考虑二分】
JS drag and drop alert pop-up plug-in
How to use redis to realize things and locks?
网络各层性能测试
Unity gadget displays the file size of the resource directory
如何平衡SQL中的安全与性能?
不懂就问,快速成为容器服务进阶玩家!
Interpretation of ue4.25 slate source code
Integrating database Ecology: using eventbridge to build CDC applications
一个程序员的水平能差到什么程度?尼玛,都是人才呀...
Unity performance optimization scheme arrangement
有奖征文 | 2022 云原生编程挑战赛征稿活动开启
How to make the design of governance structure more flexible when the homogenization token is combined with NFT?
Explain the script data transmission and notification in unity
Cartoon JS shooting game source code
激光slam:LeGO-LOAM---代码编译安装与gazebo测试