[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2015-02-13
8
Medium Priority
?
371 Views
Last Modified: 2015-03-03
I need to obtain time from an ntp server in my Java program.

How do I do that?

Thanks,


Chris
0
Comment
Question by:Christopher Schene
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 36

Assisted Solution

by:mccarl
mccarl earned 800 total points
ID: 40609288
There is nothing builtin to Java to do this, so you would manually have to create and send the right request packets and then decode the response... or you can use a library like Apache Commons Net (http://commons.apache.org/proper/commons-net/)

The page linked to above has downloads for the library (or details for getting via Maven if you use it) and also in the main info of the page is a link to an example for doing exactly what you are after. Have a go with all that and if there are any problems let us know.
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 40610084
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.
0
 

Author Comment

by:Christopher Schene
ID: 40610506
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.
0
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 
LVL 36

Expert Comment

by:mccarl
ID: 40610697
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.
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 40610972
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 ...
0
 

Accepted Solution

by:
Christopher Schene earned 0 total points
ID: 40615819
I found this java example though I have not tried it yet.
blah.java
0
 
LVL 36

Expert Comment

by:mccarl
ID: 40615823
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.
0
 

Author Closing Comment

by:Christopher Schene
ID: 40641311
I did most of the work: I found the example on the net. the other experts made suggestions and provided a link.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question