I have values that I have to add as hours, the problem is that these values reach me as double
, where the first number is the hour and the second is the minutes, that is, for example:
valueA = 09.30 - > 9 hours and 30 minutes
valueB = 01.45 - > 1 hour and 45 minutes
totalValue = valueA + ValueB
I am using jodatime
doing the following
LocalDateTime totalHoras = new LocalDateTime()
.withHourOfDay(0)
.withMinuteOfHour(0)
.withSecondOfMinute(0);
Double value1 = entry1.getValue();
Double value2 = partesTrabajoIdHorasLocal.get(key);
String value1String = new SimpleDateFormat("HH:mm").format(value1);
String value2String = new SimpleDateFormat("HH:mm").format(value2);
totalHoras = totalHoras.plusHours(obtenerHoras(String.valueOf(value1String)));
totalHoras = totalHoras.plusMinutes(obtenerMinutos(String.valueOf(value2String)));
totalHoras = totalHoras.plusHours(obtenerHoras(String.valueOf(value1String)));
totalHoras = totalHoras.plusMinutes(obtenerMinutos(String.valueOf(value2String)));