현재 하루의 시작 시간과 종료 시간을 가져 와서 두 시간의 차이를 계산하여 하루 종일 근무한 시간을 제공하는 기능이 있습니다. 내가하고 싶은 일은 7 일 동안 근무한 시간을 얻고, 표시 형식 (HH : mm)을 유지하면서 총계를 반환 할 수 있습니다. 대한JodaTime 주당 근무한 총 시간을 계산하십시오
내 기능 총 하루의 :
Period p = new Period(this.startTime[dayIndex], this.endTime[dayIndex]);
long hours = p.getHours();
long minutes = p.getMinutes();
String format = String.format("%%0%dd", 2);//Ensures that the minutes will always display as two digits.
return Long.toString(hours)+":"+String.format(format, minutes);
this.startTime [] & this.endTime [] 날짜 시간 객체의 두 배열입니다.
제안 사항?
'format'은''% 02d "'로 대체 될 수 있습니다. – BalusC