【发布时间】:2015-02-16 11:01:12
【问题描述】:
我正在尝试从 GPS 获取时间戳。
我正在使用 onLocationChanged 方法和 Date 类,如下所示:
public void onLocationChanged(Location location) {
Date date = new Date(location.getTime());
Log.d("TIME","day "+Calendar.get);
Log.d("TIME","month "+date.getMonth());
Log.d("TIME","year "+date.getYear());
Log.d("TIME","hour "+date.getHours());
Log.d("TIME","minutes "+date.getMinutes());
Log.d("TIME","seconds "+date.getSeconds());
}
现在我知道这些方法已被弃用,但它仍然可以给我准确的结果,对吧?
分钟、秒和小时都可以,但是:
天值为 1。
月份值为 1。
年份值为 115 。
我如何知道问题出在我从某个位置到达的时间上,还是日期类搞砸了?
【问题讨论】: