SntpClient client = new SntpClient();
String mNtpServer = "xtra1.gpsonextra.net";
if(client.requestTime(mNtpServer, 10000)) { // Network Time
long time = client.getNtpTime();
Date currentTime = new Date();
currentTime.setTime(time);
String mTime = DateFormat.format("yyyyMMddTkkmmss", currentTime).toString();
return mTime;
} else { // System Time
Log.e(LOG_TAG, "Request NETWORK_TIME Failed");
return DateFormat.format("yyyyMMddTkkmmss", new Date()).toString();
}
全站熱搜
留言列表