本文整理汇总了Java中java.time.temporal.ChronoUnit.MILLIS属性的典型用法代码示例。如果您正苦于以下问题:Java ChronoUnit.MILLIS属性的具体用法?Java ChronoUnit.MILLIS怎么用?Java ChronoUnit.MILLIS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.time.temporal.ChronoUnit
的用法示例。
在下文中一共展示了ChronoUnit.MILLIS属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toChronoUnit
/**
* To chrono unit.
*
* @param tu the tu
* @return the chrono unit
*/
public static ChronoUnit toChronoUnit(final TimeUnit tu) {
if (tu == null) {
return null;
}
switch (tu) {
case DAYS:
return ChronoUnit.DAYS;
case HOURS:
return ChronoUnit.HOURS;
case MINUTES:
return ChronoUnit.MINUTES;
case SECONDS:
return ChronoUnit.SECONDS;
case MICROSECONDS:
return ChronoUnit.MICROS;
case MILLISECONDS:
return ChronoUnit.MILLIS;
case NANOSECONDS:
return ChronoUnit.NANOS;
default:
return null;
}
}
示例2: chronoUnit
/**
* Converts a {@code TimeUnit} to a {@code ChronoUnit}.
* <p>
* This handles the seven units declared in {@code TimeUnit}.
*
* @param unit the unit to convert, not null
* @return the converted unit, not null
*/
private static ChronoUnit chronoUnit(final TimeUnit unit) {
Objects.requireNonNull(unit, "unit");
switch (unit) {
case NANOSECONDS:
return ChronoUnit.NANOS;
case MICROSECONDS:
return ChronoUnit.MICROS;
case MILLISECONDS:
return ChronoUnit.MILLIS;
case SECONDS:
return ChronoUnit.SECONDS;
case MINUTES:
return ChronoUnit.MINUTES;
case HOURS:
return ChronoUnit.HOURS;
case DAYS:
return ChronoUnit.DAYS;
default:
throw new IllegalArgumentException("Unknown TimeUnit constant");
}
}
示例3: toChronoUnit
private static ChronoUnit toChronoUnit(TimeUnit unit) {
Objects.requireNonNull(unit, "unit");
switch (unit) {
case NANOSECONDS:
return ChronoUnit.NANOS;
case MICROSECONDS:
return ChronoUnit.MICROS;
case MILLISECONDS:
return ChronoUnit.MILLIS;
case SECONDS:
return ChronoUnit.SECONDS;
case MINUTES:
return ChronoUnit.MINUTES;
case HOURS:
return ChronoUnit.HOURS;
case DAYS:
return ChronoUnit.DAYS;
default:
throw new IllegalArgumentException("Unknown TimeUnit constant");
}
}
示例4: getChildChronoUnit
/**
* Returns the child ChronoUnit for the given ChronoUnit.
*
* @param chronoUnit desired ChronoUnit
* @return child ChronoUnit of the given ChronoUnit
*/
@NotNull
public static ChronoUnit getChildChronoUnit(@NotNull ChronoUnit chronoUnit) {
switch (requireNonNull(chronoUnit)) {
case MICROS:
return ChronoUnit.NANOS;
case MILLIS:
return ChronoUnit.MICROS;
case SECONDS:
return ChronoUnit.MILLIS;
case MINUTES:
return ChronoUnit.SECONDS;
case HOURS:
return ChronoUnit.MINUTES;
case DAYS:
return ChronoUnit.HOURS;
case WEEKS:
return ChronoUnit.DAYS;
case MONTHS:
return ChronoUnit.WEEKS;
case YEARS:
return ChronoUnit.MONTHS;
case DECADES:
return ChronoUnit.YEARS;
case MILLENNIA:
return ChronoUnit.DECADES;
case ERAS:
return ChronoUnit.MILLENNIA;
default:
throw new UnsupportedOperationException("Unsupported chrono unit: " + chronoUnit);
}
}
示例5: data_badTemporalUnit
@DataProvider(name="BadTemporalUnit")
Object[][] data_badTemporalUnit() {
return new Object[][] {
{ChronoUnit.MICROS},
{ChronoUnit.MILLIS},
{ChronoUnit.HALF_DAYS},
{ChronoUnit.DECADES},
{ChronoUnit.CENTURIES},
{ChronoUnit.MILLENNIA},
};
}
示例6: test
@Override
@Bulkhead(waitingTaskQueue = 5, value = 5)
@Retry(retryOn =
{ BulkheadException.class }, delay = 1, delayUnit = ChronoUnit.MILLIS, maxRetries = 10, maxDuration=999999)
public Future test(BackendTestDelegate action) throws InterruptedException {
Utils.log("in business method of bean " + this.getClass().getName());
return action.perform();
}
开发者ID:eclipse,项目名称:microprofile-fault-tolerance,代码行数:8,代码来源:Bulkhead55RapidRetry10MethodSynchBean.java
示例7: run
@Override
public void run() {
ChronoUnit chronoUnit = ChronoUnit.MILLIS;
do {
Job nextJob = jobScheduler.getNextExecutableJob();
if (nextJob != null) {
ZonedDateTime nextExecution = nextJob.getNextExecution();
boolean waitFornextExecution = true;
while (waitFornextExecution && keepRunning && checkJob(nextJob)) {
long timeToNextExecution = chronoUnit.between(ZonedDateTime.now(), nextExecution);
if (timeToNextExecution <= 0) {
LOG.debug("Executing job {}.", nextJob.getJobName());
ExecutionResult executionResult = executorPool.addExecution(nextJob.getExecutor());
if (!ExecutionResult.EXECUTED.equals(executionResult)) {
jobScheduler.notifyFailingJob(nextJob.getExecutor(),executionResult);
}
nextJob.setLastExecution(ZonedDateTime.now());
waitFornextExecution = false;
} else {
LOG.trace("Waiting for next job execution in {} ms.", timeToNextExecution);
waitForNextExecution(timeToNextExecution);
}
}
} else {
waitForNextExecution(MINIMAL_TIME_STEP);
}
} while(keepRunning);
}
示例8: granularityOf
private Granularity granularityOf(long granularityValue, String granularityUnit) {
ChronoUnit unit = ChronoUnit.valueOf(granularityUnit.toUpperCase());
return unit == ChronoUnit.MILLIS ? null : Granularity.valueOf(granularityValue, unit);
}
示例9: parseDuration
static Duration parseDuration(String input) {
if (input.startsWith("P") || input.startsWith("-P") || input.startsWith("+P")) {
return Duration.parse(input);
}
String[] parts = splitNumericAndChar(input);
String numberString = parts[0];
String originalUnitString = parts[1];
String unitString = originalUnitString;
if (numberString.length() == 0) {
throw new IllegalArgumentException(String.format("No number in duration value '%s'", input));
}
if (unitString.length() > 2 && !unitString.endsWith("s")) {
unitString = unitString + "s";
}
ChronoUnit units;
switch (unitString) {
case "ns":
units = ChronoUnit.NANOS;
break;
case "us":
units = ChronoUnit.MICROS;
break;
case "":
case "ms":
units = ChronoUnit.MILLIS;
break;
case "s":
units = ChronoUnit.SECONDS;
break;
case "m":
units = ChronoUnit.MINUTES;
break;
case "h":
units = ChronoUnit.HOURS;
break;
case "d":
units = ChronoUnit.DAYS;
break;
default:
throw new IllegalArgumentException(
String.format("Could not parse time unit '%s' (try ns, us, ms, s, m, h, d)", originalUnitString));
}
return Duration.of(Long.parseLong(numberString), units);
}