List of usage examples for org.joda.time DateTime minuteOfDay
public Property minuteOfDay()
From source file:org.kuali.kpme.tklm.utils.TkTestUtils.java
License:Educational Community License
public static Map<DateTime, BigDecimal> getDateToHoursMap(TimeBlock timeBlock, TimeHourDetail timeHourDetail) { Map<DateTime, BigDecimal> dateToHoursMap = new HashMap<DateTime, BigDecimal>(); DateTime beginTime = timeBlock.getBeginDateTime(); DateTime endTime = timeBlock.getEndDateTime(); Days d = Days.daysBetween(beginTime, endTime); int numberOfDays = d.getDays(); if (numberOfDays < 1) { dateToHoursMap.put(timeBlock.getBeginDateTime(), timeHourDetail.getHours()); return dateToHoursMap; }/*from w ww .ja v a2 s .c om*/ DateTime currentTime = beginTime; for (int i = 0; i < numberOfDays; i++) { DateTime nextDayAtMidnight = currentTime.plusDays(1); nextDayAtMidnight = nextDayAtMidnight.hourOfDay().setCopy(12); nextDayAtMidnight = nextDayAtMidnight.minuteOfDay().setCopy(0); nextDayAtMidnight = nextDayAtMidnight.secondOfDay().setCopy(0); nextDayAtMidnight = nextDayAtMidnight.millisOfSecond().setCopy(0); Duration dur = new Duration(currentTime, nextDayAtMidnight); long duration = dur.getStandardSeconds(); BigDecimal hrs = new BigDecimal(duration / 3600, HrConstants.MATH_CONTEXT); dateToHoursMap.put(currentTime, hrs); currentTime = nextDayAtMidnight; } Duration dur = new Duration(currentTime, endTime); long duration = dur.getStandardSeconds(); BigDecimal hrs = new BigDecimal(duration / 3600, HrConstants.MATH_CONTEXT); dateToHoursMap.put(currentTime, hrs); return dateToHoursMap; }