本文整理汇总了Java中org.apache.commons.lang3.time.DurationFormatUtils.formatDurationWords方法的典型用法代码示例。如果您正苦于以下问题:Java DurationFormatUtils.formatDurationWords方法的具体用法?Java DurationFormatUtils.formatDurationWords怎么用?Java DurationFormatUtils.formatDurationWords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.time.DurationFormatUtils
的用法示例。
在下文中一共展示了DurationFormatUtils.formatDurationWords方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: player
import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
@RequestMapping("/t/{tempo}/m/{mode}/players/{name}")
public ModelAndView player(@PathVariable("tempo") Tempo tempo, @PathVariable("mode") String mode, @PathVariable("name") String name) {
GameMode gameMode = gameModes.find(GameModeId.of(mode)).orElseThrow(NotAvailableException::new);
PlayerStats playerStats = playerStatsRepository.playerStatsOps(tempo).playerStats(gameMode.getId(), name).orElseGet(() -> PlayerStats.of(gameMode.getId(), name));
Map<Badge, BadgeLevel> badgeLevels = badgeRepository.badgeOps(tempo).badgeLevels(gameMode.getId(), name);
Function<Long, String> x = m -> DurationFormatUtils.formatDurationWords(m, true, false);
return
new ModelAndView("player")
.addObject("tempo", tempo)
.addObject("name", name)
.addObject("gameMode", gameMode)
.addObject("gameModes", gameModes)
.addObject("stats", playerStats)
.addObject("badges", gameMode.getBadges())
.addObject("badgeLevels", badgeLevels)
.addObject("durationFormatter", x)
;
}
示例2: appendDeadlineInformation
import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
private void appendDeadlineInformation(StringBuilder sb, WorkItemEvent event) {
WorkItemType workItem = event.getWorkItem();
if (!isDone(event) && workItem.getDeadline() != null) {
XMLGregorianCalendar deadline = workItem.getDeadline();
long before = XmlTypeConverter.toMillis(deadline) - System.currentTimeMillis();
long beforeRounded = Math.round((double) before / 60000.0) * 60000L;
String beforeWords = DurationFormatUtils.formatDurationWords(Math.abs(beforeRounded), true, true);
String beforePhrase;
if (beforeRounded > 0) {
beforePhrase = " (in " + beforeWords + ")";
} else if (beforeRounded < 0) {
beforePhrase = " (" + beforeWords + " ago)";
} else {
beforePhrase = "";
}
sb.append("Deadline: ").append(textFormatter.formatDateTime(deadline)).append(beforePhrase).append("\n");
sb.append("\n");
}
}
示例3: setDefaultCaptureMillis
import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
/**
* Sets the default time in milliseconds to capture this {@link CaptureZone}.
*
* @param millis
* the milliseconds to set
*/
public void setDefaultCaptureMillis(long millis) {
if (this.defaultCaptureMillis != millis) {
this.defaultCaptureMillis = millis;
this.defaultCaptureWords = DurationFormatUtils.formatDurationWords(millis, true, true);
}
}
示例4: getSubjectFromWorkItemEvent
import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
private String getSubjectFromWorkItemEvent(WorkItemEvent event, GeneralNotifierType generalNotifierType, String transport,
Task task, OperationResult result) {
if (event instanceof WorkItemLifecycleEvent) {
if (event.isAdd()) {
return "A new work item has been created";
} else if (event.isDelete()) {
if (event.getOperationKind() == WorkItemOperationKindType.COMPLETE) {
return "Work item has been completed";
} else {
return "Work item has been cancelled";
}
} else {
throw new UnsupportedOperationException("workItemLifecycle event with MODIFY operation is not supported");
}
} else if (event instanceof WorkItemAllocationEvent) {
if (event.isAdd()) {
return "Work item has been allocated to you";
} else if (event.isModify()) {
if (event.getOperationKind() == null) {
throw new IllegalStateException("Missing operationKind in " + event);
}
String rv = "Work item will be automatically " + getOperationPastTenseVerb(event.getOperationKind());
if (event.getTimeBefore() != null) { // should always be
rv += " in " + DurationFormatUtils.formatDurationWords(
event.getTimeBefore().getTimeInMillis(new Date()), true, true);
}
return rv;
} else {
return "Work item has been " + getOperationPastTenseVerb(event.getOperationKind());
}
} else if (event instanceof WorkItemCustomEvent) {
return "A notification about work item";
} else {
throw new UnsupportedOperationException("Unsupported event type for event=" + event);
}
}
示例5: convertMilisToTime
import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
public static String convertMilisToTime(long time) {
return DurationFormatUtils.formatDurationWords(time, true, true);
}
示例6: uptime
import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/uptime", method = RequestMethod.GET)
public String uptime() {
return DurationFormatUtils.formatDurationWords(ManagementFactory.getRuntimeMXBean().getUptime(), false, false);
}
示例7: RepairRunStatus
import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
public RepairRunStatus(
UUID runId,
String clusterName,
String keyspaceName,
Collection<String> columnFamilies,
int segmentsRepaired,
int totalSegments,
RepairRun.RunState state,
DateTime startTime,
DateTime endTime,
String cause,
String owner,
String lastEvent,
DateTime creationTime,
DateTime pauseTime,
double intensity,
boolean incrementalRepair,
RepairParallelism repairParallelism,
Collection<String> nodes,
Collection<String> datacenters,
Collection<String> blacklistedTables) {
this.id = runId;
this.cause = cause;
this.owner = owner;
this.clusterName = clusterName;
this.columnFamilies = columnFamilies;
this.keyspaceName = keyspaceName;
this.state = state;
this.creationTime = creationTime;
this.startTime = startTime;
this.endTime = endTime;
this.pauseTime = pauseTime;
this.intensity = roundDoubleNicely(intensity);
this.incrementalRepair = incrementalRepair;
this.totalSegments = totalSegments;
this.repairParallelism = repairParallelism;
this.segmentsRepaired = segmentsRepaired;
this.lastEvent = lastEvent;
this.nodes = nodes;
this.datacenters = datacenters;
this.blacklistedTables = blacklistedTables;
if (startTime == null || endTime == null) {
duration = null;
} else {
duration = DurationFormatUtils.formatDurationWords(
new Duration(startTime.toInstant(), endTime.toInstant()).getMillis(), true, false);
}
if (startTime == null || (endTime != null && endTime.isAfter(startTime))) {
estimatedTimeOfArrival = null;
} else {
if (state == RepairRun.RunState.ERROR
|| state == RepairRun.RunState.DELETED
|| state == RepairRun.RunState.ABORTED
|| segmentsRepaired == 0) {
estimatedTimeOfArrival = null;
} else {
long now = DateTime.now().getMillis();
long currentDuration = now - startTime.getMillis();
long millisecondsPerSegment = currentDuration / segmentsRepaired;
int segmentsLeft = totalSegments - segmentsRepaired;
estimatedTimeOfArrival = new DateTime(now + millisecondsPerSegment * segmentsLeft);
}
}
}
示例8: calculateDuration
import org.apache.commons.lang3.time.DurationFormatUtils; //导入方法依赖的package包/类
private String calculateDuration(CrawlSession session) {
long start = session.getStartTime();
long stop = System.currentTimeMillis();
return DurationFormatUtils.formatDurationWords(stop - start, true, true);
}