java中如何在代码中判断时间是否过了10秒
long previous = 0L; ... { Calendar c = Calendar.getInstance(); long now = c.getTimeInMillis(); //获取当前时间 Log.d(TAG, "now-->" + now + ",,previous-->"+previous + ",,now - previous -->" + (now - previous)); if(now - previous>= 5000){ // 两次点击时间差大于5秒 // do something previous = now ; //更新 previous } // previous = now ; } return true;