当前位置:网站首页>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 边栏推荐
- Space game Lesson 12: shield
- Two written interview questions about regular
- Job CE
- Looking at SQL optimization from the whole process of one query
- 一文读懂Okaleido Tiger近期动态,挖掘背后价值与潜力
- Introduction to redis I: redis practical reading notes
- 如何平衡SQL中的安全与性能?
- Dynamic planning: code summary of knapsack problem template
- Mongoose condition queries the data of a certain time period
- Space shooting Lesson 11: sound and music
猜你喜欢

JS drag and drop alert pop-up plug-in

第六七八次作业

Explain in detail the rays and radiographic testing in unity

Cartoon JS shooting game source code

Random talk on GIS data (VI) - projection coordinate system
![[complete collection of common ADB commands and their usage (from a comprehensive summary of [wake up on Sunday)]](/img/63/91b53b0ba718537383a97df59fe573.png)
[complete collection of common ADB commands and their usage (from a comprehensive summary of [wake up on Sunday)]

什么是数据中台?数据中台带来了哪些价值?_光点科技

一个程序员的水平能差到什么程度?尼玛,都是人才呀...

什么是“安全感”?沃尔沃用它自己独特的理解以及行动来告诉你

Subcontracting loading of wechat applet
随机推荐
flask 静态文件服务搭建
Unity gadget displays the file size of the resource directory
js win7透明桌面切换背景开始菜单js特效
一个程序员的水平能差到什么程度?尼玛,都是人才呀...
How to use redis to realize things and locks?
Dynamic planning: code summary of knapsack problem template
云原生编程挑战赛火热开赛,51 万奖金等你来挑战!
7/27 训练日志(位运算+后缀数组)
什么是数据中台?数据中台带来了哪些价值?_光点科技
有奖征文 | 2022 云原生编程挑战赛征稿活动开启
Unity uses shader to quickly make a circular mask
Redis 3.0源码分析-数据结构与对象 SDS LIST DICT
Random talk on GIS data (VI) - projection coordinate system
Oracle库访问很慢,是什么原因?
Explain the mobile control implementation of unity in detail
JS fly into JS special effect pop-up login box
Mongoose condition queries part of the data of the specified attribute
Explain in detail the rays and radiographic testing in unity
Explain mesh Collider in unity
What is "security"? Volvo tells you with its unique understanding and action