我想从手机中获取确切的当前时间并将其发送到服务器。但它在 25 分钟附近变化并不完全......它的变化
我无法获得正确的系统时间
在这里我展示了代码,我尝试过的
final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+5:30"));
int hr = cal.get(Calendar.HOUR_OF_DAY);
int min = cal.get(Calendar.MINUTE);
int sec = cal.get(Calendar.SECOND);
int day = cal.get(Calendar.DAY_OF_MONTH);
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
String date;
SimpleDateFormat sdf = new SimpleDateFormat("dd:mm:yyyy HH:mm:ss z");
String test = sdf.format(cal.getTime());
String months = String.valueOf(month + 1);
String days = String.valueOf(day);
String years = String.valueOf(year);
String time = hr+":"+min+":"+sec;
请帮我解决这个问题。