本文整理汇总了Java中org.joda.time.Minutes类的典型用法代码示例。如果您正苦于以下问题:Java Minutes类的具体用法?Java Minutes怎么用?Java Minutes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Minutes类属于org.joda.time包,在下文中一共展示了Minutes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCronIntervalLessThanMinimum
import org.joda.time.Minutes; //导入依赖的package包/类
/**
* Checks if the given cron expression interval is less or equals to a certain minimum.
*
* @param cronExpression the cron expression to check
*/
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());
}
}
示例2: haveConnectorCacheIntervalsLapsed
import org.joda.time.Minutes; //导入依赖的package包/类
boolean haveConnectorCacheIntervalsLapsed(final AttributeConnectorService localConnectorService,
final DateTime policyEvalTimestampUTC) {
DateTime nowUTC = currentDateUTC();
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;
}
示例3: getReservationHeaders
import org.joda.time.Minutes; //导入依赖的package包/类
private Map<String, String> getReservationHeaders(Http.RequestHeader request, User user) {
Map<String, String> headers = new HashMap<>();
Optional<ExamEnrolment> ongoingEnrolment = getNextEnrolment(user.getId(), 0);
if (ongoingEnrolment.isPresent()) {
handleOngoingEnrolment(ongoingEnrolment.get(), request, headers);
} else {
DateTime now = new DateTime();
int lookAheadMinutes = Minutes.minutesBetween(now, now.plusDays(1).withMillisOfDay(0)).getMinutes();
Optional<ExamEnrolment> upcomingEnrolment = getNextEnrolment(user.getId(), lookAheadMinutes);
if (upcomingEnrolment.isPresent()) {
handleUpcomingEnrolment(upcomingEnrolment.get(), request, headers);
} else if (isOnExamMachine(request)) {
// User is logged on an exam machine but has no exams for today
headers.put("x-exam-upcoming-exam", "none");
}
}
return headers;
}
示例4: get_interval
import org.joda.time.Minutes; //导入依赖的package包/类
private String get_interval(DateTime largerDatetime, DateTime smallerDateTime) throws HydraClientException{
int year_diff = Years.yearsBetween(smallerDateTime, largerDatetime).getYears();
int month_diff = Months.monthsBetween(smallerDateTime, largerDatetime).getMonths();
int day_diff = Days.daysBetween(smallerDateTime, largerDatetime).getDays();
int hour_diff = Hours.hoursBetween(smallerDateTime, largerDatetime).getHours();
int min_diff = Minutes.minutesBetween(smallerDateTime, largerDatetime).getMinutes();
if (year_diff > 0){return year_diff+"YEAR";}
if (month_diff > 0){return month_diff+"MONTH";}
if (day_diff > 0){return day_diff+"DAY";}
if (hour_diff > 0){return hour_diff+"HOUR";}
if (min_diff > 0){return min_diff+"MIN";}
throw new HydraClientException("Could not compute interval between times " + smallerDateTime.toString() + "and" + largerDatetime.toString());
}
示例5: getBacklogBytes
import org.joda.time.Minutes; //导入依赖的package包/类
/**
* Gets total size in bytes of all events that remain in Kinesis stream between specified
* instants.
*
* @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(new Callable<Long>() {
@Override
public Long call() throws Exception {
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;
}
});
}
示例6: shouldCountBytesWhenSingleDataPointReturned
import org.joda.time.Minutes; //导入依赖的package包/类
@Test
public void shouldCountBytesWhenSingleDataPointReturned() throws Exception {
Instant countSince = new Instant("2017-04-06T10:00:00.000Z");
Instant countTo = new Instant("2017-04-06T11:00:00.000Z");
Minutes periodTime = Minutes.minutesBetween(countSince, countTo);
GetMetricStatisticsRequest metricStatisticsRequest =
underTest.createMetricStatisticsRequest(STREAM, countSince, countTo, periodTime);
GetMetricStatisticsResult result = new GetMetricStatisticsResult()
.withDatapoints(new Datapoint().withSum(1.0));
given(cloudWatch.getMetricStatistics(metricStatisticsRequest)).willReturn(result);
long backlogBytes = underTest.getBacklogBytes(STREAM, countSince, countTo);
assertThat(backlogBytes).isEqualTo(1L);
}
示例7: shouldCountBytesWhenMultipleDataPointsReturned
import org.joda.time.Minutes; //导入依赖的package包/类
@Test
public void shouldCountBytesWhenMultipleDataPointsReturned() throws Exception {
Instant countSince = new Instant("2017-04-06T10:00:00.000Z");
Instant countTo = new Instant("2017-04-06T11:00:00.000Z");
Minutes periodTime = Minutes.minutesBetween(countSince, countTo);
GetMetricStatisticsRequest metricStatisticsRequest =
underTest.createMetricStatisticsRequest(STREAM, countSince, countTo, periodTime);
GetMetricStatisticsResult result = new GetMetricStatisticsResult()
.withDatapoints(
new Datapoint().withSum(1.0),
new Datapoint().withSum(3.0),
new Datapoint().withSum(2.0)
);
given(cloudWatch.getMetricStatistics(metricStatisticsRequest)).willReturn(result);
long backlogBytes = underTest.getBacklogBytes(STREAM, countSince, countTo);
assertThat(backlogBytes).isEqualTo(6L);
}
示例8: shouldHandleGetBacklogBytesError
import org.joda.time.Minutes; //导入依赖的package包/类
private void shouldHandleGetBacklogBytesError(
Exception thrownException,
Class<? extends Exception> expectedExceptionClass) {
Instant countSince = new Instant("2017-04-06T10:00:00.000Z");
Instant countTo = new Instant("2017-04-06T11:00:00.000Z");
Minutes periodTime = Minutes.minutesBetween(countSince, countTo);
GetMetricStatisticsRequest metricStatisticsRequest =
underTest.createMetricStatisticsRequest(STREAM, countSince, countTo, periodTime);
given(cloudWatch.getMetricStatistics(metricStatisticsRequest)).willThrow(thrownException);
try {
underTest.getBacklogBytes(STREAM, countSince, countTo);
failBecauseExceptionWasNotThrown(expectedExceptionClass);
} catch (Exception e) {
assertThat(e).isExactlyInstanceOf(expectedExceptionClass);
} finally {
reset(kinesis);
}
}
示例9: updateSummaryBar
import org.joda.time.Minutes; //导入依赖的package包/类
private void updateSummaryBar() {
tripSummaryFrom.setText(DataStringUtils.removeCaltrain(possibleTrip.getFirstStopName()));
tripSummaryTo.setText(DataStringUtils.removeCaltrain(possibleTrip.getLastStopName()));
tripSummaryPrice.setText(String.format(Locale.getDefault(), "$%.2f", possibleTrip.getPrice()));
if (possibleTrip.getArrivalTime().getHourOfDay() >= possibleTrip.getDepartureTime().getHourOfDay()) {
tripSummaryTotalTime.setText(String.format(Locale.getDefault(), "%d min", Minutes.minutesBetween(possibleTrip.getDepartureTime(), possibleTrip.getArrivalTime()).getMinutes()));
} else {
tripSummaryTotalTime.setText(String.format(Locale.getDefault(), "%d min", Minutes.minutesBetween(possibleTrip.getDepartureTime().toDateTimeToday(), possibleTrip.getArrivalTime().toDateTimeToday().plusHours(24)).getMinutes()));
}
tripSummaryNumber.setText(possibleTrip.getTripShortName());
tripSummaryDateTime.setText(DateTimeFormat.forPattern("E, MMM d").print(stopDateTime));
if (possibleTrip.getRouteLongName().contains("Bullet")) {
tripSummaryImage.setImageDrawable(getActivity().getDrawable(R.drawable.ic_train_bullet));
tripSummaryImage.setContentDescription(getString(R.string.bullet_train));
} else {
tripSummaryImage.setImageDrawable(getActivity().getDrawable(R.drawable.ic_train_local));
tripSummaryImage.setContentDescription(getString(R.string.local_train));
}
}
示例10: onBindViewHolder
import org.joda.time.Minutes; //导入依赖的package包/类
@Override
public void onBindViewHolder(RouteViewHolder holder, int position) {
PossibleTrain possibleTrain = possibleTrains.get(position);
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("h:mma");
Integer minutes = Minutes.minutesBetween(now, possibleTrain.getDepartureTime().toDateTimeToday()).getMinutes();
holder.stopCardTrainItemNumber.setText(possibleTrain.getTripShortName());
holder.stopCardTrainItemTime.setTypeface(null, Typeface.NORMAL);
holder.stopCardTrainItemBack.setBackgroundColor(ContextCompat.getColor(activity, R.color.cardview_light_background));
if (possibleTrain.getRouteLongName().contains("Bullet")) {
holder.stopCardTrainItemImage.setImageDrawable(activity.getDrawable(R.drawable.ic_train_bullet));
} else {
holder.stopCardTrainItemImage.setImageDrawable(activity.getDrawable(R.drawable.ic_train_local));
}
if (minutes >= 0 && minutes <= 60) {
holder.stopCardTrainItemTime.setText(String.format(Locale.getDefault(), "in %d min", minutes));
holder.stopCardTrainItemTime.setTypeface(null, Typeface.ITALIC);
holder.stopCardTrainItemBack.setBackgroundColor(ContextCompat.getColor(activity, R.color.cardview_light_background));
} else {
holder.stopCardTrainItemTime.setText(dateTimeFormatter.print(possibleTrain.getDepartureTime()));
}
}
示例11: mergeFile
import org.joda.time.Minutes; //导入依赖的package包/类
public static void mergeFile() {
String rootPath = "D:/bdsoft/vko/tianli_act_code";
String destPath = rootPath + "/all_code.txt";
File rootDir = new File(rootPath);
if (rootDir.exists()) {
File[] fileArr = rootDir.listFiles();
DateTime start = new DateTime();
System.out.println("开始:" + start.toLocalDateTime());
for (File file : fileArr) {
readFrom(destPath, file);
}
DateTime end = new DateTime();
System.out.println("结束:" + end.toLocalDateTime());
String msg = String.format("文件合并完毕,耗时:%s分 %s秒", (Minutes.minutesBetween(start, end).getMinutes() % 60),
(Seconds.secondsBetween(start, end).getSeconds() % 3600));
System.out.println(msg);
}
}
示例12: computeTimeModeAndDiff
import org.joda.time.Minutes; //导入依赖的package包/类
private int computeTimeModeAndDiff(DateTime dmin, DateTime dmax) {
int diffDay = Days.daysBetween(dmin, dmax).getDays();
int diffHou = Hours.hoursBetween(dmin, dmax).getHours();
int diffMin = Minutes.minutesBetween(dmin, dmax).getMinutes();
int diffSec = Seconds.secondsBetween(dmin, dmax).getSeconds();
int diff = diffMin;
guessTimeMode(diffDay, diffHou, diffMin, diffSec);
if (TimeMode.DAY.equals(timeMode)) {
diff = diffDay;
} else if (TimeMode.HOUR.equals(timeMode)) {
diff = diffHou;
} else if (TimeMode.MINUTE.equals(timeMode)) {
diff = diffMin;
} else if (TimeMode.SECOND.equals(timeMode)) {
diff = diffSec;
}
//consoleDiffs(diffDay, diffHou, diffMin, diffSec, diff);
return diff;
}
示例13: getMissedImportantMessages
import org.joda.time.Minutes; //导入依赖的package包/类
@Override
@SqlReadonlyTransactional
public Collection<Message> getMissedImportantMessages(User user) {
List<Message> messages = new ArrayList<Message>();
for (SocialNetworkService sns : socialNetworkServices) {
messages.addAll(sns.getMissedIncomingMessages(user));
}
DateTime lastLogout = new DateTime(user.getLastLogout());
// if the last logout was less than an hour ago, assume it was 12 hours ago,
// so that more messages are displayed (although they might not be actually 'missed')
if (Minutes.minutesBetween(lastLogout, new DateTime()).getMinutes() < 60) {
lastLogout = new DateTime().minusHours(12);
}
messages.addAll(dao.getIncomingMessages(user,
followingService.getFollowing(user.getId()), lastLogout));
filterByImportantMessageThreshold(user.getProfile().getImportantMessageScoreThreshold(),
user.getProfile().getImportantMessageScoreThresholdRatio(), user, messages);
messages = filterAndFillMetadata(user, messages,
Collections.<Message> emptyList(), false, true);
return messages;
}
示例14: dateToAge
import org.joda.time.Minutes; //导入依赖的package包/类
private static String dateToAge(String createdAt, DateTime now) {
if (createdAt == null) {
return "";
}
DateTimeFormatter dtf = DateTimeFormat.forPattern(DATE_TIME_FORMAT);
try {
DateTime created = dtf.parseDateTime(createdAt);
if (Seconds.secondsBetween(created, now).getSeconds() < 60) {
return Seconds.secondsBetween(created, now).getSeconds() + "s";
} else if (Minutes.minutesBetween(created, now).getMinutes() < 60) {
return Minutes.minutesBetween(created, now).getMinutes() + "m";
} else if (Hours.hoursBetween(created, now).getHours() < 24) {
return Hours.hoursBetween(created, now).getHours() + "h";
} else {
return Days.daysBetween(created, now).getDays() + "d";
}
} catch (IllegalArgumentException e) {
return "";
}
}
示例15: analyzeTime
import org.joda.time.Minutes; //导入依赖的package包/类
public AlarmResults analyzeTime(List<EGVRecord> egvRecords, GlucoseUnit unit, DateTime downloadTime) {
AlarmResults results = new AlarmResults();
if (egvRecords.size() == 0) {
return results;
}
DateTime lastRecordWallTime = egvRecords.get(egvRecords.size() - 1).getWallTime();
if (preferences.isStaleAlarmEnabled()) {
if (lastRecordWallTime.plus(ALARM_TIMEAGO_URGENT_MINS).isBeforeNow()) {
Log.d("Alarm", "Urgent stale data");
results.setSeverityAtHighest(AlarmSeverity.URGENT);
results.appendMessage(context.getString(R.string.alarm_timeago_urgent_message, Minutes.minutesBetween(lastRecordWallTime, Instant.now()).getMinutes()));
results.title = context.getString(R.string.alarm_timeago_standard_title);
} else if (lastRecordWallTime.plus(ALARM_TIMEAGO_WARN_MINS).isBeforeNow()) {
Log.d("Alarm", "Warning stale data");
results.setSeverityAtHighest(AlarmSeverity.WARNING);
results.appendMessage(context.getString(R.string.alarm_timeago_warn_message, egvRecords.get(egvRecords.size() - 1).getReading().asStr(unit), unit.name(), Minutes.minutesBetween(lastRecordWallTime, Instant.now()).getMinutes()));
results.title = context.getString(R.string.alarm_timeago_standard_title);
}
}
if (downloadTime.minus(Minutes.minutes(5)).isAfter(lastRecordWallTime)) {
Log.d("OOR", "Out of range detected");
results.appendMessage(context.getString(R.string.alarm_out_of_range_message, Minutes.minutesBetween(lastRecordWallTime, Instant.now()).getMinutes()));
}
return results;
}