java将系统时间与我获取它的时间进行比较
我收到错误:-
仪器状态:stack=安卓。util。TimeFormatException:字符串太短--应至少包含8个字符
public void test() {
TextView onDeviceTime = (TextView) mNextUIMainActivity.findViewById(R.id.timeOfDay);
Time onSystem = new Time();
onSystem.setToNow();
Time onLauncherDisplay = new Time();
onSystem.parse(onDeviceTime.getText().toString());
if (onDeviceTime.equals(onSystem)) {
System.out.println("Correct time!");
}
}
# 1 楼答案
您正在尝试比较
Time
对象和TextView
对象。听起来你真正想要的是if (onLauncherDisplay.equals(onSystem))