List of usage examples for java.time Duration between
public static Duration between(Temporal startInclusive, Temporal endExclusive)
From source file:org.kitodo.production.services.data.ProcessService.java
/** * Calculate and return duration/age of given process as a String. * * @param process ProcessDTO object for which duration/age is calculated * @return process age of given process// w w w.j a v a2 s . c o m */ public static String getProcessDuration(ProcessDTO process) { String creationDateTimeString = process.getCreationDate(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); LocalDateTime createLocalDate = LocalDateTime.parse(creationDateTimeString, formatter); Duration duration = Duration.between(createLocalDate, LocalDateTime.now()); return String.format("%sd; %sh", duration.toDays(), duration.toHours() - TimeUnit.DAYS.toHours(duration.toDays())); }
From source file:org.openecomp.sdc.be.model.operations.impl.ComponentOperation.java
public Either<List<ComponentInstance>, StorageOperationStatus> getAllComponentInstncesMetadata( String componentId, NodeTypeEnum nodeType) { Instant start = Instant.now(); Either<List<ComponentInstance>, StorageOperationStatus> resourceInstancesOfService = componentInstanceOperation .getAllComponentInstancesMetadataOnly(componentId, nodeType); Instant end = Instant.now(); log.debug("TOTAL TIME BL GET INSTANCES: {}", Duration.between(start, end)); // prints // PT1M3.553S return resourceInstancesOfService; }