Thales IoT Developer Community
NTP - How to use net time protocol on J2ME
Showcase, February 18, 2015 - 10:43am, 4094 views
Attached an example how to get the time form a NTP server.
Find source attached, comments are included.
If you want to run the code please modify the APN in regards to the used SIM/MNO
sntpclient.setApn("apn of your mobile operator"); (IMlet.java - line 22)
If needed setters for username and password are available in the SntpClient.java object as well.
Log file of the debug session:
Registering ip address "192.168.244.1" of remote debugging device...
Waiting for debug device registration of "IMP_NG_EHS5_REMOTE"...
Passing control to external device emulator...
Installing suite from: http://192.168.244.2:51968/NTPExample.jad
Connection state: CONNECTING
Connection state: UP
HTTP response: Found
NTP request sent, waiting for response...
NTP server: 126.96.36.199
Leap indicator: 0
Root delay: 5.8746337890625 ms
Root dispersion: 66.4520263671875 ms
Reference identifier: 188.8.131.52
Reference timestamp: Wed Feb 18 07:35:48 GMT+00:00 2015, fraction 0.8753509521484375
Originate timestamp: Thu Jan 08 21:17:09 GMT+00:00 2004, fraction 0.694000244140625
Receive timestamp: Wed Feb 18 08:08:37 GMT+00:00 2015, fraction 0.010018348693847656
Transmit timestamp: Wed Feb 18 08:08:37 GMT+00:00 2015, fraction 0.010127067565917969
Dest. timestamp: Thu Jan 08 21:17:10 GMT+00:00 2004, fraction 0.21899986267089844
Round-trip delay: 524.8908996582031 ms
Local clock offset: 3.5065028705357263E11 ms
Local time 3.50650287E8sec late
97402h 51m 27s
End of debug session. Emulator is closed!