Java: Get current Date and Time from Server not System clock

前端 未结 4 1227
天涯浪人
天涯浪人 2020-11-27 08:05

In my Java program, I need to create an instance of the current moment in time. I use

Date date = new Date();

This gives me the current dat

4条回答
  •  误落风尘
    2020-11-27 08:19

    You could have a look at the Java NTP Client demo available at

    http://www.docjar.com/html/api/examples/ntp/NTPClient.java.html

    and some example code that utilizes this client

    http://www.docjar.com/html/api/examples/ntp/TimeClient.java.html

    It's about 170 lines of well documented java code.

提交回复
热议问题