0

I have a Java program that needs the current date and time. This is normally easily done, but if the user's system date/time is incorrectly set it could present issues for my software.

I want to pull the current date/time from an external server, so I was thinking I could use a Java implementation of an NTP client to pull a POSIX UTC timestamp from a public NTP server (e.g. pool.ntp.org) as that's way more dependable and cost effective than me running my own server(s) for this purpose.

Is NTP a good solution here, or is there a better protocol that I'm unaware of?

Salis
  • 433
  • 1
  • 8
  • 15

1 Answers1

0

I've used apache commons NTP before which is fine, unless you're running on windows and need millisecond accuracy, in which case, read this answer.

Community
  • 1
  • 1
Steve Atkinson
  • 1,219
  • 2
  • 12
  • 30