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();

}

arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()