List of usage examples for org.joda.time Minutes minutesBetween
public static Minutes minutesBetween(ReadablePartial start, ReadablePartial end)
Minutes
representing the number of whole minutes between the two specified partial datetimes. From source file:net.sourceforge.fenixedu.domain.LessonInstance.java
License:Open Source License
private int getUnitMinutes() { return Minutes.minutesBetween(getStartTime(), getEndTime()).getMinutes(); }
From source file:net.sourceforge.fenixedu.domain.teacher.DegreeTeachingService.java
License:Open Source License
public double getTotalHoursAfter20AndSaturdays() { int minutesAfter20AndSaturday = 0; for (Lesson lesson : getShift().getAssociatedLessonsSet()) { for (Interval lessonInterval : lesson.getAllLessonIntervals()) { if (lessonInterval.getStart().getDayOfWeek() == DateTimeConstants.SATURDAY) { minutesAfter20AndSaturday += Minutes .minutesBetween(lessonInterval.getStart(), lessonInterval.getEnd()).getMinutes(); } else { DateTime dateTimeAfter20 = lessonInterval.getStart().toLocalDate() .toDateTime(new LocalTime(20, 0, 0)); if (dateTimeAfter20.isBefore(lessonInterval.getEnd())) { if (!dateTimeAfter20.isAfter(lessonInterval.getStart())) { minutesAfter20AndSaturday += Minutes .minutesBetween(lessonInterval.getStart(), lessonInterval.getEnd()) .getMinutes(); } else { minutesAfter20AndSaturday += Minutes .minutesBetween(dateTimeAfter20, lessonInterval.getEnd()).getMinutes(); }/*from w ww . ja v a 2 s .co m*/ } } } } return (double) minutesAfter20AndSaturday / DateTimeConstants.MINUTES_PER_HOUR; }
From source file:net.technicpack.launcher.ui.components.news.AuthorshipWidget.java
License:Open Source License
private String getDateText(Date date) { LocalDate posted = new LocalDate(date.getTime()); LocalDate now = new LocalDate(); Years yearsSince = Years.yearsBetween(posted, now); Months monthsSince = Months.monthsBetween(posted, now); Days daysSince = Days.daysBetween(posted, now); Hours hoursSince = Hours.hoursBetween(posted, now); Minutes minutesSince = Minutes.minutesBetween(posted, now); if (yearsSince.getYears() > 1) return resources.getString("time.years", Integer.toString(yearsSince.getYears())); else if (yearsSince.getYears() == 1) return resources.getString("time.year"); else if (monthsSince.getMonths() > 1) return resources.getString("time.months", Integer.toString(monthsSince.getMonths())); else if (monthsSince.getMonths() == 1) return resources.getString("time.month"); else if (daysSince.getDays() > 1) return resources.getString("time.days", Integer.toString(daysSince.getDays())); else if (daysSince.getDays() == 1) return resources.getString("time.day"); else if (hoursSince.getHours() > 1) return resources.getString("time.hours", Integer.toString(hoursSince.getHours())); else if (hoursSince.getHours() == 1) return resources.getString("time.hour"); else if (minutesSince.getMinutes() > 1) return resources.getString("time.minutes", Integer.toString(minutesSince.getMinutes())); else//from ww w .ja va2 s. c o m return resources.getString("time.minute"); }
From source file:net.willwebberley.gowertides.classes.Tide.java
License:Open Source License
public String getTimeDifference(Calendar cal) { int h_diff = Math .abs(Hours.hoursBetween(new DateTime(time.getTime()), new DateTime(cal.getTime())).getHours() % 24); int m_diff = Math .abs(Minutes.minutesBetween(new DateTime(time.getTime()), new DateTime(cal.getTime())).getMinutes() % 60);//from www. ja v a 2s. c om String h_diff_s = h_diff + ""; String m_diff_s = m_diff + ""; if (m_diff < 10) { m_diff_s = "0" + m_diff_s; } boolean negative = true; // negative if time of tide BEHIND current time long milli_diff = cal.getTime().getTime() - time.getTime().getTime(); if (milli_diff < 0) { negative = false; } if (negative) { return "-" + h_diff_s + ":" + m_diff_s; } else { return "+" + h_diff_s + ":" + m_diff_s; } }
From source file:org.apache.beam.sdk.io.kinesis.SimplifiedKinesisClient.java
License:Apache License
/** * Gets total size in bytes of all events that remain in Kinesis stream between specified * instants.//from w w w . j av a 2 s . c om * * @return total size in bytes of all Kinesis events after specified instant */ public long getBacklogBytes(final String streamName, final Instant countSince, final Instant countTo) throws TransientKinesisException { return wrapExceptions(() -> { Minutes period = Minutes.minutesBetween(countSince, countTo); if (period.isLessThan(Minutes.ONE)) { return 0L; } GetMetricStatisticsRequest request = createMetricStatisticsRequest(streamName, countSince, countTo, period); long totalSizeInBytes = 0; GetMetricStatisticsResult result = cloudWatch.getMetricStatistics(request); for (Datapoint point : result.getDatapoints()) { totalSizeInBytes += point.getSum().longValue(); } return totalSizeInBytes; }); }
From source file:org.apache.pig.piggybank.evaluation.datetime.diff.ISOMinutesBetween.java
License:Apache License
@Override public Long exec(Tuple input) throws IOException { if (input == null || input.size() < 2) { return null; }//from w ww .j a v a 2s . c o m // Set the time to default or the output is in UTC DateTimeZone.setDefault(DateTimeZone.UTC); DateTime startDate = new DateTime(input.get(0).toString()); DateTime endDate = new DateTime(input.get(1).toString()); // Larger date first Minutes m = Minutes.minutesBetween(endDate, startDate); long minutes = m.getMinutes(); return minutes; }
From source file:org.apereo.portal.events.aggr.AggregationIntervalInfo.java
License:Apache License
/** @return Minutes between {@link #getStart()} and {@link #getEnd()} */ public int getTotalDuration() { int d = this.duration; if (d < 0) { d = Minutes.minutesBetween(this.start, this.end).getMinutes(); d = Math.abs(d);//from ww w . jav a 2s . co m this.duration = d; } return d; }
From source file:org.apereo.portal.events.aggr.AggregationIntervalInfo.java
License:Apache License
/** * @return Minutes between {@link #getStart()} and the end parameter, if the parameter is after * {@link #getEnd()} then {@link #getEnd()} is used *//*ww w . j a v a2 s . c o m*/ public int getDurationTo(ReadableInstant end) { if (end.isAfter(this.end)) { return this.getTotalDuration(); } return Math.abs(Minutes.minutesBetween(this.start, end).getMinutes()); }
From source file:org.artifactory.cron.CronUtils.java
License:Open Source License
/** * Checks if the given cron expression interval is less or equals to a certain minimum. * * @param cronExpression the cron expression to check *//*from www .java2 s. c o m*/ public static boolean isCronIntervalLessThanMinimum(String cronExpression) { try { // If input is empty or invalid simply return false as default if (StringUtils.isBlank(cronExpression) || !isValid(cronExpression)) { return false; } CronExpression cron = new CronExpression(cronExpression); final Date firstExecution = cron.getNextValidTimeAfter(new Date(System.currentTimeMillis())); final Date secondExecution = cron.getNextValidTimeAfter(firstExecution); Minutes intervalMinutes = Minutes.minutesBetween(new DateTime(firstExecution), new DateTime(secondExecution)); return !intervalMinutes.isGreaterThan(MINIMUM_ALLOWED_MINUTES); } catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); } }
From source file:org.eclipse.keti.acs.policy.evaluation.cache.EntityType.java
License:Apache License
boolean haveConnectorCacheIntervalsLapsed(final AttributeConnectorService localConnectorService, final DateTime policyEvalTimestampUTC) { DateTime nowUTC = currentDateUTC();//from w w w . j ava 2 s . c o m int decisionAgeMinutes = Minutes.minutesBetween(policyEvalTimestampUTC, nowUTC).getMinutes(); boolean hasResourceConnectorIntervalLapsed = localConnectorService.isResourceAttributeConnectorConfigured() && decisionAgeMinutes >= localConnectorService.getResourceAttributeConnector() .getMaxCachedIntervalMinutes(); boolean hasSubjectConnectorIntervalLapsed = localConnectorService.isSubjectAttributeConnectorConfigured() && decisionAgeMinutes >= localConnectorService.getSubjectAttributeConnector() .getMaxCachedIntervalMinutes(); return hasResourceConnectorIntervalLapsed || hasSubjectConnectorIntervalLapsed; }