當前位置: 首頁>>代碼示例>>Java>>正文


Java Minutes類代碼示例

本文整理匯總了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());
    }
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:24,代碼來源:CronUtils.java

示例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;
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:17,代碼來源:AbstractPolicyEvaluationCache.java

示例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;
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:19,代碼來源:SystemRequestHandler.java

示例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());
	
}
 
開發者ID:UMWRG,項目名稱:DSSApp,代碼行數:17,代碼來源:DSSExport.java

示例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;
    }
  });
}
 
開發者ID:apache,項目名稱:beam,代碼行數:32,代碼來源:SimplifiedKinesisClient.java

示例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);
}
 
開發者ID:apache,項目名稱:beam,代碼行數:17,代碼來源:SimplifiedKinesisClientTest.java

示例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);
}
 
開發者ID:apache,項目名稱:beam,代碼行數:21,代碼來源:SimplifiedKinesisClientTest.java

示例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);
  }
}
 
開發者ID:apache,項目名稱:beam,代碼行數:20,代碼來源:SimplifiedKinesisClientTest.java

示例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));
  }
}
 
開發者ID:eleith,項目名稱:calchoochoo,代碼行數:24,代碼來源:TripSummaryFragment.java

示例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()));
  }
}
 
開發者ID:eleith,項目名稱:calchoochoo,代碼行數:25,代碼來源:StopTrainsAdapter.java

示例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);
    }
}
 
開發者ID:bdceo,項目名稱:bd-codes,代碼行數:20,代碼來源:TianliActCode.java

示例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;
}
 
開發者ID:jzy3d,項目名稱:bigpicture,代碼行數:25,代碼來源:HistogramDate.java

示例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;
}
 
開發者ID:Glamdring,項目名稱:welshare,代碼行數:26,代碼來源:MessageServiceImpl.java

示例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 "";
    }
}
 
開發者ID:zfoltin,項目名稱:twittererer,代碼行數:23,代碼來源:TimelineConverter.java

示例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;
}
 
開發者ID:nightscout,項目名稱:lasso,代碼行數:26,代碼來源:Alarm.java


注:本文中的org.joda.time.Minutes類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。