本文整理了Java中org.sonar.api.utils.Duration.encode()
方法的一些代码示例,展示了Duration.encode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Duration.encode()
方法的具体详情如下:
包路径:org.sonar.api.utils.Duration
类名称:Duration
方法名:encode
[英]Return the duration in text, by using the given hours in day parameter to process hours.
Duration.decode("1d 1h", 8).encode(8) will return "1d 1h" Duration.decode("2d", 8).encode(16) will return "1d"
[中]通过使用给定的小时数参数来处理小时数,以文本形式返回持续时间。
期间解码(“1d 1h”,8)。编码(8)将返回“1d 1h”持续时间。解码(“2d”,8)。编码(16)将返回“1d”
代码示例来源:origin: SonarSource/sonarqube
/**
* Return the string value of the Duration.
* <br>
* Example : encode(Duration.encode("9d 10h")) -> "10d2h"
*/
public String encode(Duration duration) {
return duration.encode(HOURS_IN_DAY);
}
代码示例来源:origin: SonarSource/sonarqube
@CheckForNull
private static String sanitizeValue(String label, @Nullable String s) {
if (StringUtils.isNotBlank(s)) {
try {
Duration duration = Duration.decode(s, HOURS_IN_DAY);
return duration.encode(HOURS_IN_DAY);
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Invalid %s: %s (%s)", label, s, e.getMessage()), e);
}
}
return null;
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void encode() {
assertThat(Duration.create(2 * ONE_DAY_IN_MINUTES + 5 * ONE_HOUR_IN_MINUTES + 46 * ONE_MINUTE).encode(HOURS_IN_DAY)).isEqualTo("2d5h46min");
assertThat(Duration.create(ONE_DAY_IN_MINUTES).encode(HOURS_IN_DAY)).isEqualTo("1d");
assertThat(Duration.create(ONE_HOUR_IN_MINUTES).encode(HOURS_IN_DAY)).isEqualTo("1h");
assertThat(Duration.create(HOURS_IN_DAY * ONE_HOUR_IN_MINUTES).encode(HOURS_IN_DAY)).isEqualTo("1d");
assertThat(Duration.create(ONE_MINUTE).encode(HOURS_IN_DAY)).isEqualTo("1min");
assertThat(Duration.create(0).encode(HOURS_IN_DAY)).isEqualTo("0min");
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api
/**
* Return the string value of the Duration.
* <br>
* Example : encode(Duration.encode("9d 10h")) -> "10d2h"
*/
public String encode(Duration duration) {
return duration.encode(HOURS_IN_DAY);
}
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
/**
* Return the string value of the Duration.
* <br>
* Example : encode(Duration.encode("9d 10h")) -> "10d2h" (if sonar.technicalDebt.hoursInDay property is set to 8)
*/
public String encode(Duration duration) {
return duration.encode(hoursInDay());
}
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
@CheckForNull
private String sanitizeValue(String label, @Nullable String s) {
if (StringUtils.isNotBlank(s)) {
try {
Duration duration = Duration.decode(s, HOURS_IN_DAY);
return duration.encode(HOURS_IN_DAY);
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Invalid %s: %s (%s)", label, s, e.getMessage()), e);
}
}
return null;
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api
@CheckForNull
private static String sanitizeValue(String label, @Nullable String s) {
if (StringUtils.isNotBlank(s)) {
try {
Duration duration = Duration.decode(s, HOURS_IN_DAY);
return duration.encode(HOURS_IN_DAY);
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Invalid %s: %s (%s)", label, s, e.getMessage()), e);
}
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!