Java Code Examples for org.joda.time.Minutes#getMinutes()

The following examples show how to use org.joda.time.Minutes#getMinutes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MedtronicHistoryData.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
private int getOldestDateDifference(List<PumpHistoryEntry> treatments) {

        long dt = Long.MAX_VALUE;
        PumpHistoryEntry currentTreatment = null;

        if (isCollectionEmpty(treatments)) {
            return 8; // default return of 6 (5 for diif on history reading + 2 for max allowed difference) minutes
        }

        for (PumpHistoryEntry treatment : treatments) {

            if (treatment.atechDateTime < dt) {
                dt = treatment.atechDateTime;
                currentTreatment = treatment;
            }
        }

        LocalDateTime oldestEntryTime = null;

        try {

            oldestEntryTime = DateTimeUtil.toLocalDateTime(dt);
            oldestEntryTime = oldestEntryTime.minusMinutes(3);

//            if (this.pumpTime.timeDifference < 0) {
//                oldestEntryTime = oldestEntryTime.plusSeconds(this.pumpTime.timeDifference);
//            }
        } catch (Exception ex) {
            LOG.error("Problem decoding date from last record: {}" + currentTreatment);
            return 8; // default return of 6 minutes
        }

        LocalDateTime now = new LocalDateTime();

        Minutes minutes = Minutes.minutesBetween(oldestEntryTime, now);

        // returns oldest time in history, with calculated time difference between pump and phone, minus 5 minutes
        if (isLogEnabled())
            LOG.debug("Oldest entry: {}, pumpTimeDifference={}, newDt={}, currentTime={}, differenceMin={}", dt,
                    this.pumpTime.timeDifference, oldestEntryTime, now, minutes.getMinutes());

        return minutes.getMinutes();
    }
 
Example 2
Source File: IntegerColumnMinutesMapper.java    From jadira with Apache License 2.0 4 votes vote down vote up
@Override
public String toNonNullString(Minutes value) {
    return "" + value.getMinutes();
}
 
Example 3
Source File: IntegerColumnMinutesMapper.java    From jadira with Apache License 2.0 4 votes vote down vote up
@Override
public Integer toNonNullValue(Minutes value) {
    return value.getMinutes();
}
 
Example 4
Source File: MinutesBetweenDates.java    From levelup-java-examples with Apache License 2.0 3 votes vote down vote up
@Test
public void minutes_between_two_dates_in_java_with_joda () {
	
	// start day is 1 day in the past
	DateTime startDate = new DateTime().minusDays(1);
	DateTime endDate = new DateTime();
	
	Minutes minutes = Minutes.minutesBetween(startDate, endDate);
	
	int numberOfMinutesInDay = minutes.getMinutes();
	
	assertEquals(1440, numberOfMinutesInDay);
}
 
Example 5
Source File: DateTimeUtil.java    From AndroidAPS with GNU Affero General Public License v3.0 2 votes vote down vote up
public static int getATechDateDiferenceAsMinutes(Long date1, Long date2) {

        Minutes minutes = Minutes.minutesBetween(toLocalDateTime(date1), toLocalDateTime(date2));

        return minutes.getMinutes();
    }