List of usage examples for org.apache.commons.lang3.time DurationFormatUtils formatDurationWords
public static String formatDurationWords(final long durationMillis, final boolean suppressLeadingZeroElements, final boolean suppressTrailingZeroElements)
Formats an elapsed time into a plurialization correct string.
This method formats durations using the days and lower fields of the format pattern.
From source file:com.feilong.core.date.DateExtensionUtilTest.java
/** * Test get interval for view long./*w ww .ja v a 2 s. c om*/ */ @Test public void testGetIntervalForViewLong() { assertEquals("25841", getIntervalForView(25841)); assertEquals("0", getIntervalForView(0)); LOGGER.debug(DurationFormatUtils.formatDurationWords(25841, true, true)); }
From source file:com.publictransitanalytics.scoregenerator.output.TimeQualifiedPointAccessibility.java
public TimeQualifiedPointAccessibility(final PathScoreCard scoreCard, final Grid grid, final Center center, final LocalDateTime time, final Duration tripDuration, final boolean backward, final Duration inServiceTime) throws InterruptedException { type = AccessibilityType.TIME_QUALIFIED_POINT_ACCESSIBILITY; direction = backward ? Direction.INBOUND : Direction.OUTBOUND; mapBounds = new Bounds(grid.getBounds()); this.center = new Point(center.getLogicalCenter().getPointRepresentation()); this.time = time.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.tripDuration = DurationFormatUtils.formatDurationWords(tripDuration.toMillis(), true, true); final ImmutableMap.Builder<Bounds, FullSectorReachInformation> builder = ImmutableMap.builder(); final TaskIdentifier task = new TaskIdentifier(time, center); final Set<Sector> sectors = grid.getAllSectors(); for (final Sector sector : sectors) { final MovementPath sectorPath = scoreCard.getBestPath(sector, task); if (sectorPath != null) { final Bounds sectorBounds = new Bounds(sector); builder.put(sectorBounds, new FullSectorReachInformation(sectorPath)); }/* w ww. j a v a 2 s . c om*/ } sectorPaths = builder.build(); totalSectors = grid.getReachableSectors().size(); inServiceSeconds = inServiceTime.getSeconds(); }
From source file:com.publictransitanalytics.scoregenerator.output.NetworkAccessibility.java
public NetworkAccessibility(final int taskCount, final ScoreCard scoreCard, final Grid grid, final Set<Sector> centerSectors, final LocalDateTime startTime, final LocalDateTime endTime, final Duration tripDuration, final Duration samplingInterval, final boolean backward, final Duration inServiceTime) throws InterruptedException { type = AccessibilityType.NETWORK_ACCESSIBILITY; direction = backward ? Direction.INBOUND : Direction.OUTBOUND; mapBounds = new Bounds(grid.getBounds()); boundsCenter = new Point(grid.getBounds().getCenter()); this.startTime = startTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.endTime = endTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.samplingInterval = DurationFormatUtils.formatDurationWords(samplingInterval.toMillis(), true, true); this.tripDuration = DurationFormatUtils.formatDurationWords(tripDuration.toMillis(), true, true); this.taskCount = taskCount; final Set<Sector> sectors = grid.getAllSectors(); totalSectors = grid.getReachableSectors().size(); final ImmutableMap.Builder<Bounds, Integer> countBuilder = ImmutableMap.builder(); for (final Sector sector : sectors) { if (scoreCard.hasPath(sector)) { final Bounds bounds = new Bounds(sector); countBuilder.put(bounds, scoreCard.getReachedCount(sector)); }// w w w .j a v a 2s . co m } sectorCounts = countBuilder.build(); this.centerPoints = centerSectors.stream().map(sector -> new Point(sector.getBounds().getCenter())) .collect(Collectors.toSet()); sampleCount = centerPoints.size(); inServiceSeconds = inServiceTime.getSeconds(); }
From source file:de.albionco.maintenance.bukkit.EnableRunnable.java
private String format(String message, int seconds) { return message.replace("{{ TIME }}", DurationFormatUtils.formatDurationWords(seconds * 1000, true, false)) .replace("{{ SECONDS }}", String.valueOf(seconds)); }
From source file:com.publictransitanalytics.scoregenerator.output.PointAccessibility.java
public PointAccessibility(final int taskCount, final PathScoreCard scoreCard, final Grid grid, final PointLocation centerPoint, final LocalDateTime startTime, final LocalDateTime lastTime, final Duration samplingInterval, final Duration tripDuration, final boolean backward, final Duration inServiceTime) throws InterruptedException { type = AccessibilityType.POINT_ACCESSIBILITY; direction = backward ? Direction.INBOUND : Direction.OUTBOUND; mapBounds = new Bounds(grid.getBounds()); center = new Point(centerPoint); this.startTime = startTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.endTime = lastTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.samplingInterval = DurationFormatUtils.formatDurationWords(samplingInterval.toMillis(), true, true); this.tripDuration = DurationFormatUtils.formatDurationWords(tripDuration.toMillis(), true, true); this.taskCount = taskCount; final Set<Sector> sectors = grid.getAllSectors(); totalSectors = grid.getReachableSectors().size(); final ImmutableMap.Builder<Bounds, SectorReachInformation> informationBuilder = ImmutableMap.builder(); for (final Sector sector : sectors) { final Map<LogicalTask, MovementPath> taskPaths = scoreCard.getBestPaths(sector); if (!taskPaths.isEmpty()) { final ImmutableSet.Builder<MovementPath> bestPathsBuilder = ImmutableSet.builder(); int count = 0; for (final MovementPath taskPath : taskPaths.values()) { if (taskPath != null) { bestPathsBuilder.add(taskPath); count++;//from w w w.j av a2 s .c o m } } final Bounds bounds = new Bounds(sector); final Set<LocalDateTime> reachTimes = scoreCard.getReachedTimes(sector); final SectorReachInformation information = new SectorReachInformation(bestPathsBuilder.build(), count, reachTimes); informationBuilder.put(bounds, information); } } sectorPaths = informationBuilder.build(); inServiceSeconds = inServiceTime.getSeconds(); }
From source file:com.publictransitanalytics.scoregenerator.output.ComparativeTimeQualifiedPointAccessibility.java
public ComparativeTimeQualifiedPointAccessibility(final PathScoreCard scoreCard, final PathScoreCard trialScoreCard, final Grid grid, final Center centerPoint, final LocalDateTime time, LocalDateTime trialTime, final Duration tripDuration, final boolean backward, final String name, final String trialName, final Duration inServiceTime, final Duration trialInServiceTime) throws InterruptedException { type = AccessibilityType.COMPARATIVE_TIME_QUALIFIED_POINT_ACCESSIBILITY; direction = backward ? Direction.INBOUND : Direction.OUTBOUND; mapBounds = new Bounds(grid.getBounds()); center = new Point(centerPoint.getLogicalCenter().getPointRepresentation()); this.time = time.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.trialTime = trialTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.tripDuration = DurationFormatUtils.formatDurationWords(tripDuration.toMillis(), true, true); final ImmutableMap.Builder<Bounds, ComparativeFullSectorReachInformation> builder = ImmutableMap.builder(); final Set<Sector> sectors = grid.getAllSectors(); final TaskIdentifier task = new TaskIdentifier(time, centerPoint); for (final Sector sector : sectors) { final MovementPath sectorPath = scoreCard.getBestPath(sector, task); final MovementPath trialSectorPath = trialScoreCard.getBestPath(sector, task); if (sectorPath != null || trialSectorPath != null) { final Bounds sectorBounds = new Bounds(sector); builder.put(sectorBounds, new ComparativeFullSectorReachInformation(sectorPath, trialSectorPath)); }//from w ww.j ava 2 s .c om } sectorPaths = builder.build(); totalSectors = grid.getReachableSectors().size(); this.name = name; this.trialName = trialName; inServiceSeconds = inServiceTime.getSeconds(); trialInServiceSeconds = trialInServiceTime.getSeconds(); }
From source file:com.serphacker.serposcope.models.base.Run.java
public String getRemainingTimeFormated() { return DurationFormatUtils.formatDurationWords(getRemainingTimeMs(), true, true); }
From source file:com.publictransitanalytics.scoregenerator.output.ComparativeNetworkAccessibility.java
public ComparativeNetworkAccessibility(final int taskCount, final int trialTaskCount, final ScoreCard scoreCard, final ScoreCard trialScoreCard, final Grid grid, final Set<Sector> centerSectors, final LocalDateTime startTime, final LocalDateTime endTime, final LocalDateTime trialStartTime, final LocalDateTime trialEndTime, final Duration tripDuration, final Duration samplingInterval, final boolean backward, final String trialName, final Duration inServiceTime, final Duration trialInServiceTime) throws InterruptedException { type = AccessibilityType.COMPARATIVE_NETWORK_ACCESSIBILITY; direction = backward ? Direction.INBOUND : Direction.OUTBOUND; mapBounds = new Bounds(grid.getBounds()); boundsCenter = new Point(grid.getBounds().getCenter()); this.startTime = startTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.endTime = endTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.trialStartTime = trialStartTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.trialEndTime = trialEndTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.samplingInterval = DurationFormatUtils.formatDurationWords(samplingInterval.toMillis(), true, true); this.tripDuration = DurationFormatUtils.formatDurationWords(tripDuration.toMillis(), true, true); this.taskCount = taskCount; this.trialTaskCount = trialTaskCount; final Set<Sector> sectors = grid.getAllSectors(); totalSectors = grid.getReachableSectors().size(); final ImmutableMap.Builder<Bounds, CountComparison> countBuilder = ImmutableMap.builder(); for (final Sector sector : sectors) { final int count = scoreCard.hasPath(sector) ? scoreCard.getReachedCount(sector) : 0; final int trialCount = trialScoreCard.hasPath(sector) ? trialScoreCard.getReachedCount(sector) : 0; if (count != 0 && trialCount != 0) { final Bounds bounds = new Bounds(sector); final CountComparison comparison = new CountComparison(count, trialCount); countBuilder.put(bounds, comparison); }/*from w w w. ja v a2s. com*/ } sectorCounts = countBuilder.build(); this.centerPoints = centerSectors.stream().map(sector -> new Point(sector.getBounds().getCenter())) .collect(Collectors.toSet()); sampleCount = centerPoints.size(); this.trialName = trialName; inServiceSeconds = inServiceTime.getSeconds(); trialInServiceSeconds = trialInServiceTime.getSeconds(); }
From source file:com.publictransitanalytics.scoregenerator.output.ComparativePointAccessibility.java
public ComparativePointAccessibility(final int taskCount, final int trialTaskCount, final PathScoreCard scoreCard, final PathScoreCard trialScoreCard, final Grid grid, final PointLocation centerPoint, final LocalDateTime startTime, final LocalDateTime endTime, final LocalDateTime trialStartTime, final LocalDateTime trialEndTime, final Duration samplingInterval, final Duration tripDuration, final boolean backward, final String trialName, final Duration inServiceTime, final Duration trialInServiceTime) throws InterruptedException { type = AccessibilityType.COMPARATIVE_POINT_ACCESSIBILITY; direction = backward ? Direction.INBOUND : Direction.OUTBOUND; mapBounds = new Bounds(grid.getBounds()); center = new Point(centerPoint); this.startTime = startTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.endTime = endTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.trialStartTime = trialStartTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.trialEndTime = trialEndTime.format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss")); this.samplingInterval = DurationFormatUtils.formatDurationWords(samplingInterval.toMillis(), true, true); this.tripDuration = DurationFormatUtils.formatDurationWords(tripDuration.toMillis(), true, true); this.taskCount = taskCount; this.trialTaskCount = trialTaskCount; final Set<Sector> sectors = grid.getAllSectors(); totalSectors = grid.getReachableSectors().size(); final ImmutableMap.Builder<Bounds, ComparativeSectorReachInformation> informationBuilder = ImmutableMap .builder();/*from w w w . j a v a 2s .c om*/ for (final Sector sector : sectors) { final Map<LogicalTask, MovementPath> bestPaths = scoreCard.getBestPaths(sector); final Map<LogicalTask, MovementPath> trialBestPaths = trialScoreCard.getBestPaths(sector); if (!bestPaths.isEmpty() || !trialBestPaths.isEmpty()) { final Set<MovementPath> bestPathSet = getBestPathSet(bestPaths); final Set<LocalDateTime> reachTimes = scoreCard.getReachedTimes(sector); final Set<MovementPath> trialBestPathSet = getBestPathSet(trialBestPaths); final Set<LocalDateTime> trialReachTimes = trialScoreCard.getReachedTimes(sector); int numBestPaths = bestPathSet.size(); int numTrialBestPaths = trialBestPathSet.size(); final Bounds bounds = new Bounds(sector); final ComparativeSectorReachInformation information = new ComparativeSectorReachInformation( bestPathSet, numBestPaths, reachTimes, trialBestPathSet, numTrialBestPaths, trialReachTimes); informationBuilder.put(bounds, information); } } sectorPaths = informationBuilder.build(); this.trialName = trialName; inServiceSeconds = inServiceTime.getSeconds(); trialInServiceSeconds = trialInServiceTime.getSeconds(); }
From source file:eu.openanalytics.rsb.component.SystemHealthResource.java
@GET @Path("/info") @Produces({ Constants.RSB_XML_CONTENT_TYPE, Constants.RSB_JSON_CONTENT_TYPE }) public NodeInformation getInfo(@Context final ServletContext sc) { final NodeInformation info = Util.REST_OBJECT_FACTORY.createNodeInformation(); info.setName(getConfiguration().getNodeName()); info.setHealthy(nodeHealthy.get());/*from ww w . j ava 2 s. c o m*/ info.setRsbVersion(getClass().getPackage().getImplementationVersion()); info.setServletContainerInfo(sc.getServerInfo()); final OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); info.setOsLoadAverage(operatingSystemMXBean.getSystemLoadAverage()); final Runtime runtime = Runtime.getRuntime(); info.setJvmMaxMemory(runtime.maxMemory()); info.setJvmFreeMemory(runtime.freeMemory()); final RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean(); final long uptimeMilliseconds = runtimeMXBean.getUptime(); info.setUptime(uptimeMilliseconds); info.setUptimeText(DurationFormatUtils.formatDurationWords(uptimeMilliseconds, true, true)); return info; }