-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gunnar Wagenknecht
committed
Feb 12, 2024
1 parent
9ec919e
commit f70dc37
Showing
3 changed files
with
47 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
bundles/com.salesforce.bazel.sdk/src/com/salesforce/bazel/sdk/util/DurationUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*- | ||
* Copyright (c) 2024 Salesforce and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Salesforce - adapted from M2E, JDT or other Eclipse project | ||
*/ | ||
package com.salesforce.bazel.sdk.util; | ||
|
||
import java.time.Duration; | ||
import java.time.temporal.ChronoUnit; | ||
|
||
/** | ||
* Utility for {@link Duration} | ||
*/ | ||
public class DurationUtil { | ||
|
||
public static String humanReadableFormat(Duration duration) { | ||
return duration.truncatedTo(ChronoUnit.MILLIS) | ||
.toString() | ||
.substring(2) | ||
.replaceAll("(\\d[HMS])(?!$)", "$1 ") | ||
.toLowerCase(); | ||
} | ||
|
||
} |