本文整理匯總了Java中org.joda.time.Minutes.minutesBetween方法的典型用法代碼示例。如果您正苦於以下問題:Java Minutes.minutesBetween方法的具體用法?Java Minutes.minutesBetween怎麽用?Java Minutes.minutesBetween使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.Minutes
的用法示例。
在下文中一共展示了Minutes.minutesBetween方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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);
}
示例3: 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);
}
示例4: 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);
}
}
示例5: difference_between_two_dates_joda
import org.joda.time.Minutes; //導入方法依賴的package包/類
@Test
public void difference_between_two_dates_joda () {
DateTime sinceGraduation = new DateTime(1984, 6, 4, 0, 0, GregorianChronology.getInstance());
DateTime currentDate = new DateTime(); //current date
Days diffInDays = Days.daysBetween(sinceGraduation, currentDate);
Hours diffInHours = Hours.hoursBetween(sinceGraduation, currentDate);
Minutes diffInMinutes = Minutes.minutesBetween(sinceGraduation, currentDate);
Seconds seconds = Seconds.secondsBetween(sinceGraduation, currentDate);
logger.info(diffInDays.getDays());
logger.info(diffInHours.getHours());
logger.info(diffInMinutes.getMinutes());
logger.info(seconds.getSeconds());
assertTrue(diffInDays.getDays() >= 10697);
assertTrue(diffInHours.getHours() >= 256747);
assertTrue(diffInMinutes.getMinutes() >= 15404876);
assertTrue(seconds.getSeconds() >= 924292577);
}
示例6: assertTimeEquals
import org.joda.time.Minutes; //導入方法依賴的package包/類
private void assertTimeEquals(final String location,
final int type,
final int expectedHour,
final int expectedMinute,
final double riseset[])
{
final int MINUTES_DELTA = 1;
final double actualHours = riseset[type];
final String typeString = type == SunPositionAlgorithm.SET? "sunset"
: "sunrise";
final LocalTime expectedTime = new LocalTime(expectedHour, expectedMinute);
final LocalTime actualTime = toLocalTime(actualHours);
final Minutes minutes = Minutes.minutesBetween(expectedTime, actualTime);
String message = location + " " + typeString + ": expected " + expectedTime
+ "; actual " + actualTime;
System.out.println(message);
assertTrue(message, Math.abs(minutes.getMinutes()) <= MINUTES_DELTA);
}
示例7: onCreate
import org.joda.time.Minutes; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_knell);
ButterKnife.bind(this);
Birthday birthday = getBirthdayManager().get();
DateTime birDateTime = new DateTime(birthday.year, birthday.month, birthday.day, 0, 0);
Days days = Days.daysBetween(birDateTime, DateTime.now());
Hours hours = Hours.hoursBetween(birDateTime, DateTime.now());
Minutes minutes = Minutes.minutesBetween(birDateTime, DateTime.now());
Weeks weeks = Weeks.weeksBetween(birDateTime, DateTime.now());
Years years = Years.yearsBetween(birDateTime, DateTime.now());
Months months = Months.monthsBetween(birDateTime, DateTime.now());
Timber.d("onCreate: 年:%d", years.getYears());
Timber.d("onCreate: 月:%d", months.getMonths());
Timber.d("onCreate: 周:%d", weeks.getWeeks());
Timber.d("onCreate: 天數為:%d", days.getDays());
Timber.d("onCreate: 小時數為:%d", hours.getHours());
Timber.d("onCreate: 分鍾數為:%d", minutes.getMinutes());
tvYear.setText(String.valueOf(years.getYears()));
tvMonth.setText(String.valueOf(months.getMonths()));
tvWeek.setText(String.valueOf(weeks.getWeeks()));
tvDay.setText(String.valueOf(days.getDays()));
tvHour.setText(String.valueOf(hours.getHours()));
tvMinute.setText(String.valueOf(minutes.getMinutes()));
}
示例8: setTimeAgoPill
import org.joda.time.Minutes; //導入方法依賴的package包/類
private void setTimeAgoPill(DateTime start) {
if (start == null) {
return;
}
Minutes minutes = Minutes.minutesBetween(start, Instant.now());
PeriodFormatterBuilder periodFormatterBuilder = new PeriodFormatterBuilder();
if (minutes.toStandardWeeks().getWeeks() > 1) {
periodFormatterBuilder.appendWeeks().appendSuffix(getApplicationContext().getString(R.string.week), getApplicationContext().getString(R.string.weeks));
} else if (minutes.toStandardDays().getDays() > 1) {
periodFormatterBuilder.appendDays().appendSuffix(getApplicationContext().getString(R.string.day), getApplicationContext().getString(R.string.days));
} else if (minutes.toStandardHours().getHours() > 1) {
periodFormatterBuilder.appendHours().appendSuffix(getApplicationContext().getString(R.string.hour), getApplicationContext().getString(R.string.hours));
} else {
periodFormatterBuilder.appendMinutes().appendSuffix(getApplicationContext().getString(R.string.minute), getApplicationContext().getString(R.string.minutes));
}
periodFormatterBuilder.appendLiteral(" ago");
PeriodFormatter formatter = periodFormatterBuilder.toFormatter();
String pattern = "(\\d+)(.*)";
Pattern r = Pattern.compile(pattern);
Log.d("minutes", "Minutes: " + formatter.print(minutes));
Matcher m = r.matcher(formatter.print(minutes));
if (m.find()) {
String number = m.group(1);
String ago = m.group(2);
minago.update(ago, number);
}
}
示例9: step
import org.joda.time.Minutes; //導入方法依賴的package包/類
@ScheduledMethod(start = 1.0, interval = 1.0, priority = -3000)
public void step() {
DateTime dateTime = new DateTime();
Seconds seconds = Seconds.secondsBetween(previous, dateTime);
Minutes minutes = Minutes.minutesBetween(previous, dateTime);
say("It took " + minutes.getMinutes() + " minutes and "
+ seconds.getSeconds() + " seconds between ticks.");
// check whether this is the last generation/iteration
if (currentIteration == (iterationNumber - 2)) {
if (currentGeneration == (generationNumber - 1)) {
say("Ending instance run");
RunEnvironment.getInstance().endRun();
}
}
if (currentIteration == (iterationNumber - 1)) {
say("This is the last iteration in this gen");
currentIteration = 0;
say("Ending current generation");
System.out.println(currentGeneration);
currentGeneration++;
} else {
say("Incrementing current iteration number to: "
+ (currentIteration + 1));
currentIteration++;
}
previous = new DateTime();
}
示例10: minutes_between_two_dates_in_java_with_joda
import org.joda.time.Minutes; //導入方法依賴的package包/類
@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);
}