1
obj.date
是Unix時間戳(長)。我檢查的日期是正確的,但我不能設法得到我的兩個日期對象之間分鐘的差別。例如,當我預計接近30時,我得到4。爲什麼?分鐘日期之間2
Date now = new Date();
Date then = new Date((long)obj.date*1000);
int secondsbetweendates = (int) ((then.getTime()-now.getTime())/1000);
int minutesbetweendates = (secondsbetweendates/1000) % 60;
不應該是'int minutesbetweendates = secondsbetweendates%60;'? –
你正在使用模數,你應該分開...... –