Android 如何获取非移动日期生成的当前日期?
我想获得不依赖于移动时间的当前日期。如果用户在手机中更改日期,那么它也将返回当前日期。如何获取非手机生成的当前日期?请尝试以下代码:Android 如何获取非移动日期生成的当前日期?,android,Android,我想获得不依赖于移动时间的当前日期。如果用户在手机中更改日期,那么它也将返回当前日期。如何获取非手机生成的当前日期?请尝试以下代码: try { TimeTCPClient updateTime = new TimeTCPClient(); try { updateTime.setDefaultTimeout(60000); updateTime.c
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();
}
请尝试以下代码:
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();
}
参考这篇文章参考这篇文章