Example usage for org.joda.time DateTime minuteOfDay

List of usage examples for org.joda.time DateTime minuteOfDay

Introduction

In this page you can find the example usage for org.joda.time DateTime minuteOfDay.

Prototype

public Property minuteOfDay() 

Source Link

Document

Get the minute of day property which provides access to advanced functionality.

Usage

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;
}