Example usage for org.joda.time Minutes minutesBetween

List of usage examples for org.joda.time Minutes minutesBetween

Introduction

In this page you can find the example usage for org.joda.time Minutes minutesBetween.

Prototype

public static Minutes minutesBetween(ReadablePartial start, ReadablePartial end) 

Source Link

Document

Creates a Minutes representing the number of whole minutes between the two specified partial datetimes.

Usage

From source file:AppPackage.timeDiff.java

public String timeDiff(String time1, String time2) {

    this.time1 = time1;
    this.time2 = time2;

    DateTimeFormatter format = DateTimeFormat.forPattern("HH:mm:ss");
    DateTime dt1 = format.parseDateTime(time1);
    DateTime dt2 = format.parseDateTime(time2);

    long hours = Hours.hoursBetween(dt1, dt2).getHours() % 24;
    long minutes = Minutes.minutesBetween(dt1, dt2).getMinutes() % 60;
    //                long seconds = Seconds.secondsBetween(dt1, dt2).getSeconds() % 60;
    String diffResult = String.format("%02d:%02d:00", hours, minutes);
    return diffResult;

}

From source file:ar.com.zir.utils.DateUtils.java

License:Open Source License

/**
 * Method that uses Joda Library to obtain the difference between two dates
 * in the specified date part/*from www  . j av  a  2 s. c o  m*/
 * 
 * @param datePart the datePart to use in the calculation
 * @param date1 first Date object
 * @param date2 second Date object
 * @return the result from date1 - date2 or -1 if specified datePart is not supported
 * @see java.util.Calendar
 */
public static int dateDiff(int datePart, Date date1, Date date2) {
    Calendar cal1 = Calendar.getInstance();
    cal1.setTime(date1);
    Calendar cal2 = Calendar.getInstance();
    cal2.setTime(date2);
    switch (datePart) {
    case DATE_PART_SECOND:
        return Seconds
                .secondsBetween(new DateTime(cal2.getTimeInMillis()), new DateTime(cal1.getTimeInMillis()))
                .getSeconds();
    case DATE_PART_MINUTE:
        return Minutes
                .minutesBetween(new DateTime(cal2.getTimeInMillis()), new DateTime(cal1.getTimeInMillis()))
                .getMinutes();
    case DATE_PART_HOUR:
        return Hours.hoursBetween(new DateTime(cal2.getTimeInMillis()), new DateTime(cal1.getTimeInMillis()))
                .getHours();
    case DATE_PART_DAY:
        return Days.daysBetween(new DateTime(cal2.getTimeInMillis()), new DateTime(cal1.getTimeInMillis()))
                .getDays();
    case DATE_PART_MONTH:
        return Months.monthsBetween(new DateTime(cal2.getTimeInMillis()), new DateTime(cal1.getTimeInMillis()))
                .getMonths();
    case DATE_PART_YEAR:
        return Years.yearsBetween(new DateTime(cal2.getTimeInMillis()), new DateTime(cal1.getTimeInMillis()))
                .getYears();
    default:
        return -1;
    }

}

From source file:betalabs.libtests.unfolding.AnimatedTemporalDotsApp.java

License:Open Source License

public void drawGrowingEarthquakeDots(PVector pos, DateTime time) {

    // Marker grows over time
    int minutes = Minutes.minutesBetween(time, currentTime).getMinutes();
    int maxMinutes = 12 * 60;
    float size = constrain(map(minutes, 0, maxMinutes, 0, 30), 0, 30);

    // But fades away the colors
    float alphaValue = constrain(map(minutes, 0, maxMinutes, 100, 0), 0, 100);
    float alphaStrokeValue = constrain(map(minutes, 0, maxMinutes, 255, 0), 0, 255);

    // Draw outer (growing) ring
    fill(255, 0, 0, alphaValue);//  w w w  .j a va 2s  .c o m
    stroke(255, 0, 0, alphaStrokeValue);
    strokeWeight(1);
    ellipse(pos.x, pos.y, size * 3, size * 3);

    // Always draw the epicenter
    fill(255, 0, 0);
    ellipse(pos.x, pos.y, 4, 4);
}

From source file:cl.usach.managedbeans.EscritorioManagedBean.java

public String obtenerTiempo(Date inicio) {
    if (inicio == null)
        return "-";
    DateTime dtI = new DateTime(inicio);
    DateTime dtF = new DateTime(new Date());
    String tiempo = "";
    String aux;/*from   ww  w.j a v  a 2 s .  c  o  m*/
    if (Days.daysBetween(dtI, dtF).getDays() > 0)
        tiempo += Days.daysBetween(dtI, dtF).getDays() + " d, ";
    aux = Hours.hoursBetween(dtI, dtF).getHours() % 24 + ":";
    if (aux.length() == 2)
        aux = "0" + aux;
    tiempo += aux;
    aux = Minutes.minutesBetween(dtI, dtF).getMinutes() % 60 + "";
    if (aux.length() == 1)
        aux = "0" + aux;
    tiempo += aux + " hrs";
    return tiempo;
}

From source file:co.malm.mglam_reads.backend.util.DateDiffUtil.java

License:Apache License

/**
 * Calculates time differences using two dates, and stores it into a
 * {@linkplain java.util.Map} object.//w  ww . ja v a2s.  c o  m
 *
 * @param map calculations data
 * @param dt1 first date for diff
 * @param dt2 second date for diff
 * @see org.joda.time.DateTime
 * @see org.joda.time.Years
 * @see org.joda.time.Months
 * @see org.joda.time.Weeks
 * @see org.joda.time.Days
 * @see org.joda.time.Hours
 * @see org.joda.time.Minutes
 * @see org.joda.time.Seconds
 */
private void calculate(HashMap<String, Integer> map, DateTime dt1, DateTime dt2) {

    final int SECONDS_IN_MINUTE = 60;
    final int MINUTES_IN_HOUR = 60;
    final int HOURS_IN_DAY = 24;
    final int DAYS_IN_MONTH = 31;
    final int MONTHS_IN_YEAR = 12;
    final int WEEKS_IN_DAY = 7;

    int diffYears = Years.yearsBetween(dt1, dt2).getYears();
    if (diffYears > 0) {
        map.put("years", diffYears);
    }

    int diffMonths = Months.monthsBetween(dt1, dt2).getMonths();
    if (diffMonths >= 1 && diffMonths < MONTHS_IN_YEAR) {
        map.put("months", diffMonths);
    }

    int diffWeeks = Weeks.weeksBetween(dt1, dt2).getWeeks();
    if (diffWeeks >= 1 && diffWeeks < WEEKS_IN_DAY) {
        map.put("weeks", diffWeeks);
    }

    int diffDays = Days.daysBetween(dt1, dt2).getDays();
    if (diffDays >= 1 && diffDays < DAYS_IN_MONTH) {
        map.put("days", diffDays);
    }

    int diffHours = Hours.hoursBetween(dt1, dt2).getHours();
    if (diffHours >= 1 && diffHours < HOURS_IN_DAY) {
        map.put("hours", diffHours);
    }

    int diffMinutes = Minutes.minutesBetween(dt1, dt2).getMinutes();
    if (diffMinutes >= 1 && diffMinutes < MINUTES_IN_HOUR) {
        map.put("minutes", diffMinutes);
    }

    int diffSeconds = Seconds.secondsBetween(dt1, dt2).getSeconds();
    if (diffSeconds >= 1 && diffSeconds < SECONDS_IN_MINUTE) {
        map.put("seconds", diffSeconds);
    }
}

From source file:com.alliander.osgp.webdevicesimulator.service.OslpChannelHandler.java

License:Open Source License

private static Message createGetPowerUsageHistoryWithDatesResponse(
        final GetPowerUsageHistoryRequest powerUsageHistoryRequest) throws ParseException {

    final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMddHHmmss").withZoneUTC();

    // 20140405 220000
    final DateTime now = new DateTime();
    final DateTime dateTimeFrom = formatter
            .parseDateTime(powerUsageHistoryRequest.getTimePeriod().getStartTime());
    DateTime dateTimeUntil = formatter.parseDateTime(powerUsageHistoryRequest.getTimePeriod().getEndTime());

    final int itemsPerPage = 2;
    final int intervalMinutes = powerUsageHistoryRequest.getTermType() == HistoryTermType.Short ? 60 : 1440;
    final int usagePerItem = powerUsageHistoryRequest.getTermType() == HistoryTermType.Short ? 2400 : 57600;

    // If from in the future, return emtpy list
    final List<PowerUsageData> powerUsageDataList = new ArrayList<PowerUsageData>();
    if (dateTimeFrom.isAfter(now)) {
        return createUsageMessage(1, itemsPerPage, 1, powerUsageDataList);
    }/*from w w w.  j  a va 2  s . c  o m*/

    // Ensure until date is not in future
    dateTimeUntil = correctUsageUntilDate(dateTimeUntil, powerUsageHistoryRequest.getTermType());

    final int queryInterval = Minutes.minutesBetween(dateTimeFrom, dateTimeUntil).getMinutes();
    final int totalNumberOfItems = queryInterval / intervalMinutes;
    final int numberOfPages = (int) Math.ceil((double) totalNumberOfItems / (double) itemsPerPage);

    // Determine page number
    int currentPageNumber;
    if (powerUsageHistoryRequest.getPage() == 0) {
        currentPageNumber = 1;
    } else {
        currentPageNumber = powerUsageHistoryRequest.getPage();
    }

    int page = 1;
    int itemsToSkip = 0;
    while (currentPageNumber != page) {
        itemsToSkip += itemsPerPage;
        page++;
    }

    // Advance time to correct page starting point, last to first (like real
    // device)
    DateTime pageStartTime = dateTimeUntil.minusMinutes(intervalMinutes * itemsToSkip)
            .minusMinutes(intervalMinutes);
    final int itemsOnPage = Math.min(Math.abs(totalNumberOfItems - itemsToSkip), itemsPerPage);

    // Advance usage to start of page
    int totalUsage = (totalNumberOfItems * usagePerItem) - (usagePerItem * itemsToSkip);

    // Fill page with items
    for (int i = 0; i < itemsOnPage; i++) {
        final int range = (100) + 1;
        final int randomCumulativeMinutes = (int) (Math.random() * range) + 100;

        // Increase the meter
        final double random = usagePerItem - (usagePerItem / 50d * Math.random());
        totalUsage -= random;
        // Add power usage item to response
        final PowerUsageData powerUsageData = PowerUsageData.newBuilder()
                .setRecordTime(pageStartTime.toString(formatter)).setMeterType(MeterType.P1)
                .setTotalConsumedEnergy(totalUsage).setActualConsumedPower((int) random)
                .setPsldData(PsldData.newBuilder().setTotalLightingHours((int) random * 3))
                .setSsldData(SsldData.newBuilder().setActualCurrent1(10).setActualCurrent2(20)
                        .setActualCurrent3(30).setActualPower1(10).setActualPower2(20).setActualPower3(30)
                        .setAveragePowerFactor1(10).setAveragePowerFactor2(20).setAveragePowerFactor3(30)
                        .addRelayData(Oslp.RelayData.newBuilder()
                                .setIndex(ByteString.copyFrom(new byte[] { 1 }))
                                .setTotalLightingMinutes(INITIAL_BURNING_MINUTES - randomCumulativeMinutes))
                        .addRelayData(Oslp.RelayData.newBuilder()
                                .setIndex(ByteString.copyFrom(new byte[] { 2 }))
                                .setTotalLightingMinutes(INITIAL_BURNING_MINUTES - randomCumulativeMinutes))
                        .addRelayData(Oslp.RelayData.newBuilder()
                                .setIndex(ByteString.copyFrom(new byte[] { 3 }))
                                .setTotalLightingMinutes(INITIAL_BURNING_MINUTES - randomCumulativeMinutes))
                        .addRelayData(Oslp.RelayData.newBuilder()
                                .setIndex(ByteString.copyFrom(new byte[] { 4 }))
                                .setTotalLightingMinutes(INITIAL_BURNING_MINUTES - randomCumulativeMinutes)))
                .build();

        powerUsageDataList.add(powerUsageData);
        pageStartTime = pageStartTime.minusMinutes(intervalMinutes);

        INITIAL_BURNING_MINUTES -= CUMALATIVE_BURNING_MINUTES;
    }

    return createUsageMessage(currentPageNumber, itemsPerPage, numberOfPages, powerUsageDataList);
}

From source file:com.amediamanager.scheduled.ElasticTranscoderTasks.java

License:Apache License

protected void handleMessage(final Message message) {
    try {//from  ww w.ja v a 2  s .co  m
        LOG.info("Handling message received from checkStatus");
        ObjectNode snsMessage = (ObjectNode) mapper.readTree(message.getBody());
        ObjectNode notification = (ObjectNode) mapper.readTree(snsMessage.get("Message").asText());
        String state = notification.get("state").asText();
        String jobId = notification.get("jobId").asText();
        String pipelineId = notification.get("pipelineId").asText();
        Video video = videoService.findByTranscodeJobId(jobId);
        if (video == null) {
            LOG.warn("Unable to process result for job {} because it does not exist.", jobId);
            Instant msgTime = Instant.parse(snsMessage.get("Timestamp").asText());
            if (Minutes.minutesBetween(msgTime, new Instant()).getMinutes() > 20) {
                LOG.error("Job {} has not been found for over 20 minutes, deleting message from queue", jobId);
                deleteMessage(message);
            }
            // Leave it on the queue for now.
            return;
        }
        if ("ERROR".equals(state)) {
            LOG.warn("Job {} for pipeline {} failed to complete. Body: \n{}", jobId, pipelineId,
                    notification.get("messageDetails").asText());
            video.setThumbnailKey(videoService.getDefaultVideoPosterKey());
            videoService.save(video);
        } else {
            // Construct our url prefix: https://bucketname.s3.amazonaws.com/output/key/
            String prefix = notification.get("outputKeyPrefix").asText();
            if (!prefix.endsWith("/")) {
                prefix += "/";
            }

            ObjectNode output = ((ObjectNode) ((ArrayNode) notification.get("outputs")).get(0));
            String previewFilename = prefix + output.get("key").asText();
            String thumbnailFilename = prefix
                    + output.get("thumbnailPattern").asText().replaceAll("\\{count\\}", "00002") + ".png";
            video.setPreviewKey(previewFilename);
            video.setThumbnailKey(thumbnailFilename);
            videoService.save(video);
        }
        deleteMessage(message);
    } catch (JsonProcessingException e) {
        LOG.error("JSON exception handling notification: {}", message.getBody(), e);
    } catch (IOException e) {
        LOG.error("IOException handling notification: {}", message.getBody(), e);
    }
}

From source file:com.axelor.apps.hr.service.timesheet.TimesheetServiceImpl.java

License:Open Source License

@Transactional
public void insertTSLine(ActionRequest request, ActionResponse response) {

    User user = AuthUtils.getUser();/* www . j  a v  a 2  s.c  o  m*/
    ProjectTask projectTask = Beans.get(ProjectTaskRepository.class)
            .find(new Long(request.getData().get("project").toString()));
    Product product = Beans.get(ProductRepository.class)
            .find(new Long(request.getData().get("activity").toString()));
    LocalDate date = new LocalDate(request.getData().get("date").toString());
    if (user != null) {
        Timesheet timesheet = Beans.get(TimesheetRepository.class).all()
                .filter("self.statusSelect = 1 AND self.user.id = ?1", user.getId()).order("-id").fetchOne();
        if (timesheet == null) {
            timesheet = createTimesheet(user, date, date);
        }
        BigDecimal minutes = new BigDecimal(Minutes.minutesBetween(new LocalTime(0, 0),
                new LocalTime(request.getData().get("duration").toString())).getMinutes());
        createTimesheetLine(projectTask, product, user, date, timesheet, minutes,
                request.getData().get("comments").toString());

        Beans.get(TimesheetRepository.class).save(timesheet);
    }
}

From source file:com.axelor.apps.production.web.OperationOrderController.java

License:Open Source License

public void chargeByMachineHours(ActionRequest request, ActionResponse response) throws AxelorException {
    List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
    DateTimeFormatter parser = ISODateTimeFormat.dateTime();
    LocalDateTime fromDateTime = LocalDateTime.parse(request.getContext().get("fromDateTime").toString(),
            parser);//from   www  .  j a va  2s .  c om
    LocalDateTime toDateTime = LocalDateTime.parse(request.getContext().get("toDateTime").toString(), parser);
    LocalDateTime itDateTime = new LocalDateTime(fromDateTime);

    if (Days.daysBetween(
            new LocalDate(fromDateTime.getYear(), fromDateTime.getMonthOfYear(), fromDateTime.getDayOfMonth()),
            new LocalDate(toDateTime.getYear(), toDateTime.getMonthOfYear(), toDateTime.getDayOfMonth()))
            .getDays() > 20) {
        throw new AxelorException(String.format(I18n.get(IExceptionMessage.CHARGE_MACHINE_DAYS)),
                IException.CONFIGURATION_ERROR);
    }

    List<OperationOrder> operationOrderListTemp = operationOrderRepo.all()
            .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", fromDateTime, toDateTime)
            .fetch();
    Set<String> machineNameList = new HashSet<String>();
    for (OperationOrder operationOrder : operationOrderListTemp) {
        if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
            if (!machineNameList.contains(operationOrder.getWorkCenter().getMachine().getName())) {
                machineNameList.add(operationOrder.getWorkCenter().getMachine().getName());
            }
        }
    }
    while (!itDateTime.isAfter(toDateTime)) {
        List<OperationOrder> operationOrderList = operationOrderRepo.all()
                .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", itDateTime,
                        itDateTime.plusHours(1))
                .fetch();
        Map<String, BigDecimal> map = new HashMap<String, BigDecimal>();
        for (OperationOrder operationOrder : operationOrderList) {
            if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
                String machine = operationOrder.getWorkCenter().getMachine().getName();
                int numberOfMinutes = 0;
                if (operationOrder.getPlannedStartDateT().isBefore(itDateTime)) {
                    numberOfMinutes = Minutes.minutesBetween(itDateTime, operationOrder.getPlannedEndDateT())
                            .getMinutes();
                } else if (operationOrder.getPlannedEndDateT().isAfter(itDateTime.plusHours(1))) {
                    numberOfMinutes = Minutes
                            .minutesBetween(operationOrder.getPlannedStartDateT(), itDateTime.plusHours(1))
                            .getMinutes();
                } else {
                    numberOfMinutes = Minutes.minutesBetween(operationOrder.getPlannedStartDateT(),
                            operationOrder.getPlannedEndDateT()).getMinutes();
                }
                if (numberOfMinutes > 60) {
                    numberOfMinutes = 60;
                }
                BigDecimal percentage = new BigDecimal(numberOfMinutes).multiply(new BigDecimal(100))
                        .divide(new BigDecimal(60), 2, RoundingMode.HALF_UP);
                if (map.containsKey(machine)) {
                    map.put(machine, map.get(machine).add(percentage));
                } else {
                    map.put(machine, percentage);
                }
            }
        }
        Set<String> keyList = map.keySet();
        for (String key : machineNameList) {
            if (keyList.contains(key)) {
                Map<String, Object> dataMap = new HashMap<String, Object>();
                if (Hours.hoursBetween(fromDateTime, toDateTime).getHours() > 24) {
                    dataMap.put("dateTime", (Object) itDateTime.toString("dd/MM/yyyy HH:mm"));
                } else {
                    dataMap.put("dateTime", (Object) itDateTime.toString("HH:mm"));
                }
                dataMap.put("charge", (Object) map.get(key));
                dataMap.put("machine", (Object) key);
                dataList.add(dataMap);
            } else {
                Map<String, Object> dataMap = new HashMap<String, Object>();
                if (Hours.hoursBetween(fromDateTime, toDateTime).getHours() > 24) {
                    dataMap.put("dateTime", (Object) itDateTime.toString("dd/MM/yyyy HH:mm"));
                } else {
                    dataMap.put("dateTime", (Object) itDateTime.toString("HH:mm"));
                }
                dataMap.put("charge", (Object) BigDecimal.ZERO);
                dataMap.put("machine", (Object) key);
                dataList.add(dataMap);
            }
        }

        itDateTime = itDateTime.plusHours(1);
    }

    response.setData(dataList);
}

From source file:com.axelor.apps.production.web.OperationOrderController.java

License:Open Source License

public void chargeByMachineDays(ActionRequest request, ActionResponse response) throws AxelorException {
    List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
    DateTimeFormatter parser = ISODateTimeFormat.dateTime();
    LocalDateTime fromDateTime = LocalDateTime.parse(request.getContext().get("fromDateTime").toString(),
            parser);//from www .  j  av  a  2 s  . c  o  m
    fromDateTime = fromDateTime.withHourOfDay(0).withMinuteOfHour(0);
    LocalDateTime toDateTime = LocalDateTime.parse(request.getContext().get("toDateTime").toString(), parser);
    toDateTime = toDateTime.withHourOfDay(23).withMinuteOfHour(59);
    LocalDateTime itDateTime = new LocalDateTime(fromDateTime);
    if (Days.daysBetween(
            new LocalDate(fromDateTime.getYear(), fromDateTime.getMonthOfYear(), fromDateTime.getDayOfMonth()),
            new LocalDate(toDateTime.getYear(), toDateTime.getMonthOfYear(), toDateTime.getDayOfMonth()))
            .getDays() > 500) {
        throw new AxelorException(String.format(I18n.get(IExceptionMessage.CHARGE_MACHINE_DAYS)),
                IException.CONFIGURATION_ERROR);
    }

    List<OperationOrder> operationOrderListTemp = operationOrderRepo.all()
            .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", fromDateTime, toDateTime)
            .fetch();
    Set<String> machineNameList = new HashSet<String>();
    for (OperationOrder operationOrder : operationOrderListTemp) {
        if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
            if (!machineNameList.contains(operationOrder.getWorkCenter().getMachine().getName())) {
                machineNameList.add(operationOrder.getWorkCenter().getMachine().getName());
            }
        }
    }
    while (!itDateTime.isAfter(toDateTime)) {
        List<OperationOrder> operationOrderList = operationOrderRepo.all()
                .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", itDateTime,
                        itDateTime.plusHours(1))
                .fetch();
        Map<String, BigDecimal> map = new HashMap<String, BigDecimal>();
        for (OperationOrder operationOrder : operationOrderList) {
            if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
                String machine = operationOrder.getWorkCenter().getMachine().getName();
                int numberOfMinutes = 0;
                if (operationOrder.getPlannedStartDateT().isBefore(itDateTime)) {
                    numberOfMinutes = Minutes.minutesBetween(itDateTime, operationOrder.getPlannedEndDateT())
                            .getMinutes();
                } else if (operationOrder.getPlannedEndDateT().isAfter(itDateTime.plusHours(1))) {
                    numberOfMinutes = Minutes
                            .minutesBetween(operationOrder.getPlannedStartDateT(), itDateTime.plusHours(1))
                            .getMinutes();
                } else {
                    numberOfMinutes = Minutes.minutesBetween(operationOrder.getPlannedStartDateT(),
                            operationOrder.getPlannedEndDateT()).getMinutes();
                }
                if (numberOfMinutes > 60) {
                    numberOfMinutes = 60;
                }
                int numberOfMinutesPerDay = 0;
                if (operationOrder.getWorkCenter().getMachine().getWeeklyPlanning() != null) {
                    DayPlanning dayPlanning = weeklyPlanningService.findDayPlanning(
                            operationOrder.getWorkCenter().getMachine().getWeeklyPlanning(),
                            new LocalDate(itDateTime));
                    numberOfMinutesPerDay = Minutes
                            .minutesBetween(dayPlanning.getMorningFrom(), dayPlanning.getMorningTo())
                            .getMinutes();
                    numberOfMinutesPerDay += Minutes
                            .minutesBetween(dayPlanning.getAfternoonFrom(), dayPlanning.getAfternoonTo())
                            .getMinutes();
                } else {
                    numberOfMinutesPerDay = 60 * 8;
                }
                BigDecimal percentage = new BigDecimal(numberOfMinutes).multiply(new BigDecimal(100))
                        .divide(new BigDecimal(numberOfMinutesPerDay), 2, RoundingMode.HALF_UP);
                if (map.containsKey(machine)) {
                    map.put(machine, map.get(machine).add(percentage));
                } else {
                    map.put(machine, percentage);
                }
            }
        }
        Set<String> keyList = map.keySet();
        for (String key : machineNameList) {
            if (keyList.contains(key)) {
                int found = 0;
                for (Map<String, Object> mapIt : dataList) {
                    if (mapIt.get("dateTime").equals((Object) itDateTime.toString("dd/MM/yyyy"))
                            && mapIt.get("machine").equals((Object) key)) {
                        mapIt.put("charge", new BigDecimal(mapIt.get("charge").toString()).add(map.get(key)));
                        found = 1;
                        break;
                    }

                }
                if (found == 0) {
                    Map<String, Object> dataMap = new HashMap<String, Object>();

                    dataMap.put("dateTime", (Object) itDateTime.toString("dd/MM/yyyy"));
                    dataMap.put("charge", (Object) map.get(key));
                    dataMap.put("machine", (Object) key);
                    dataList.add(dataMap);
                }
            }
        }

        itDateTime = itDateTime.plusHours(1);
    }

    response.setData(dataList);
}