Link to home
Start Free TrialLog in
Avatar of Christopher Schene
Christopher ScheneFlag for United States of America

asked on

How,in Java, do I obtain NTP time from one of the US time servers (us.pool.ntp.org)?

I need to obtain time from an ntp server in my Java program.

How do I do that?

Thanks,


Chris
SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There are examples for to query a NTP server for the time around on the net, I've seen one on stackoverflow.com, written in C#. Shouldn't be that much complicated to port to Java.

Just search for "query NTP server socket" on Google. Sorry for not posting the code itself, but I don't want to publish other people's code under my name.
Avatar of Christopher Schene

ASKER

Thanks for your advice.

With respect I pay for EE membership precisely because I generally do not wish to do the leg work of finding answers to my Java language question,  I am sure I will eventually be able to figure this out on my own if I've no other choice but I would rather something close to an answer. I can probably translate .net or c++ answers to Java.


I will look at the common library and see if there is something there I can use, but if I figure out the answer I split credit between the expert and myself with me getting most of the points.
Also with respect, I can't download the library for you and if you are after code that is a bit more specific to your situation than the example, then you would actually have had to give us more details about your situation.

If you were after a solution that didn't involve using a 3rd party library, then it maybe a good idea to state that in your initial question, or at least in a comment prior to making threats of splitting points, etc.
With respect, too, I did most of the legwork for you ... I just don't want to put another man's feathers on my hat. I've found a nice and short example code in C#, and I pointed you right the way to it ...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That is exactly what I was referring to in my initial comment, ie. that is the example off the Apache Commons Net page and to use it requires downloading the library.
I did most of the work: I found the example on the net. the other experts made suggestions and provided a link.