2012-08-24 2 views
0

내 캘린더를 앱에서 사용하지만 캘린더를 사용하면 timeInMillis가 잘못되었습니다. system 반환 1345846849921캘린더 리턴 시간이 잘못됨

now, 내 시간대에 1345848049917
nowSystem.currentTimeMillis()과 동일해야하지만되지 않습니다 : 예를 들어

// Get Current Time 
Calendar calNow = Calendar.getInstance(); 
calNow.setTimeInMillis(System.currentTimeMillis()); 
calNow.add(Calendar.HOUR, calNow.get(Calendar.HOUR_OF_DAY)); 
calNow.add(Calendar.MINUTE, calNow.get(Calendar.MINUTE)); 
long now = calNow.getTimeInMillis(); 

now 반환 :
난 당신에게 예를 보여 : 25.08.2012 - 00:40:49
System.currentTimeMillis()은 : 25.08.2012 - 00:20:49

정확하게 20 분 후, 그러나 왜?

답변

3

난 당신이 뭘하려고했는지 아주 잘 모르겠지만, 이러한 행

calNow.add(Calendar.HOUR, calNow.get(Calendar.HOUR_OF_DAY)); 
calNow.add(Calendar.MINUTE, calNow.get(Calendar.MINUTE)); 

00:40:4900:20:49 선회, 하루의 시간과 분을 두 배로.