我想获取不依赖于移动时间的当前日期。如果用户在移动设备中更改日期,则它将返回当前日期。如何获取移动设备未生成的当前日期?
答案 0 :(得分:0)
试试这段代码:
try {
TimeTCPClient updateTime = new TimeTCPClient();
try {
updateTime.setDefaultTimeout(60000);
updateTime.connect("your time server name...");
Log.d("TimeLog", client.getDate() + "");
} finally {
updateTime.disconnect();
}
} catch (IOException e) {
e.printStackTrace();
}