本文整理了Java中java.time.temporal.ChronoUnit.getDuration()
方法的一些代码示例,展示了ChronoUnit.getDuration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ChronoUnit.getDuration()
方法的具体详情如下:
包路径:java.time.temporal.ChronoUnit
类名称:ChronoUnit
方法名:getDuration
[英]Gets the estimated duration of this unit in the ISO calendar system.
All of the units in this class have an estimated duration. Days vary due to daylight saving time, while months have different lengths.
[中]获取此单位在ISO日历系统中的估计持续时间。
本课程中的所有单元都有一个估计的持续时间。日因夏令时而不同,而月则有不同的长度。
代码示例来源:origin: neo4j/neo4j
private Duration nextDurationRaw()
{
return Duration.ofSeconds( nextLong( DAYS.getDuration().getSeconds() ), nextLong( NANOS_PER_SECOND ) );
}
代码示例来源:origin: debezium/debezium
/**
* Converts a number of time units to a duration in microseconds.
*
* @param years a number of years
* @param months a number of months
* @param days a number of days
* @param hours a number of hours
* @param minutes a number of minutes
* @param seconds a number of seconds
* @param micros a number of microseconds
* @param daysPerMonthAvg an optional value representing a days per month average; if null, the default duration
* from {@link ChronoUnit#MONTHS} is used.
* @return a {@link BigDecimal} value which contains the number of microseconds, never {@code null}
*/
public static double durationMicros(int years, int months, int days, int hours, int minutes, double seconds,
int micros, Double daysPerMonthAvg) {
if (daysPerMonthAvg == null) {
daysPerMonthAvg = (double) ChronoUnit.MONTHS.getDuration().toDays();
}
double numberOfDays = ((years * 12) + months) * daysPerMonthAvg + days;
double numberOfSeconds = (((numberOfDays * 24 + hours) * 60) + minutes) * 60 + seconds;
return numberOfSeconds * 1e6 + micros;
}
代码示例来源:origin: ehcache/ehcache3
@Test
public void neverGoAfterInfinite() {
Duration afterInfinite = ChronoUnit.FOREVER.getDuration();
Timeouts t = TimeoutsBuilder.timeouts()
.read(afterInfinite)
.write(afterInfinite)
.connection(afterInfinite)
.build();
assertThat(t.getReadOperationTimeout()).isEqualTo(Timeouts.INFINITE_TIMEOUT);
assertThat(t.getWriteOperationTimeout()).isEqualTo(Timeouts.INFINITE_TIMEOUT);
assertThat(t.getConnectionTimeout()).isEqualTo(Timeouts.INFINITE_TIMEOUT);
}
}
代码示例来源:origin: rakam-io/rakam
dateUnit.getTemporalUnit().getDuration().toMillis(),
dateUnit.getTemporalUnit().getDuration().toMillis(),
代码示例来源:origin: rakam-io/rakam
@BeforeSuite
public void setup() throws Exception {
EventBuilder builder = new EventBuilder(PROJECT_NAME, getMetastore());
getMetastore().createProject(PROJECT_NAME);
for (int cIdx = 0; cIdx < 2; cIdx++) {
final int finalCIdx = cIdx;
List<Event> events = IntStream.range(0, SCALE_FACTOR).mapToObj(i -> builder.createEvent("test" + finalCIdx,
ImmutableMap.<String, Object>builder()
.put("teststr", "test" + (i % 2))
.put("_user", "test" + (i % 2))
.put("_time", Instant.ofEpochSecond(i * DAYS.getDuration().getSeconds())).build()))
.collect(Collectors.toList());
getEventStore().storeBatch(events);
}
}
代码示例来源:origin: com.github.crisposs/jabs-api
public static Duration infinity() {
return ChronoUnit.FOREVER.getDuration();
}
代码示例来源:origin: io.gravitee.repository/gravitee-repository
@Override
public Long from() {
return end - (time * chronoUnit.getDuration().toMillis());
}
代码示例来源:origin: io.gravitee.repository/gravitee-repository
public static Interval interval(ChronoUnit unit, int interval) {
return () -> unit.getDuration().toMillis() * interval;
}
代码示例来源:origin: org.ojalgo/ojalgo
public Duration getDuration() {
if (myChronoUnit != null) {
return myChronoUnit.getDuration();
} else { // QUARTER
return ChronoUnit.MONTHS.getDuration().multipliedBy(3L);
}
}
代码示例来源:origin: optimatika/ojAlgo
public Duration getDuration() {
if (myChronoUnit != null) {
return myChronoUnit.getDuration();
} else { // QUARTER
return ChronoUnit.MONTHS.getDuration().multipliedBy(3L);
}
}
代码示例来源:origin: ChronixDB/chronix.server
/**
* @param args the first value is the time span e.g. 5, 10, the second one is the unit of the time span
*/
@Override
public void setArguments(String[] args) {
this.timeSpan = Long.parseLong(args[0]);
this.unit = ChronoUnit.valueOf(args[1].toUpperCase());
this.windowTime = unit.getDuration().toMillis() * timeSpan;
}
代码示例来源:origin: ChronixDB/chronix.server
/**
* @param args the first value is the amount, e.g 10, the second one is the unit, e.g HOURS
*/
@Override
public void setArguments(String[] args) {
this.amount = Long.parseLong(args[0]);
this.unit = ChronoUnit.valueOf(args[1].toUpperCase());
this.shift = unit.getDuration().toMillis() * amount;
}
代码示例来源:origin: org.apache.rya/rya.api
/**
* Returns the duration in milliseconds
*
* @param duration - amount of time in the units indicated by the provided {@link OWLTime} URI
* @param uri - OWLTime URI indicating the time unit of duration (not null)
* @return - the amount of time in milliseconds
* @throws IllegalArgumentException if provided {@link URI} is not a valid, supported OWL-Time time unit.
*/
public static long getMillis(int duration, URI uri) throws IllegalArgumentException {
Optional<ChronoUnit> unit = getChronoUnitFromURI(uri);
checkArgument(unit.isPresent(),
String.format("URI %s does not indicate a valid OWLTime time unit. URI must of be of type %s, %s, %s, %s, or %s .", uri,
SECONDS_URI, MINUTES_URI, HOURS_URI, DAYS_URI, WEEKS_URI));
return duration * unit.get().getDuration().toMillis();
}
代码示例来源:origin: apache/incubator-rya
/**
* Returns the duration in milliseconds
*
* @param duration - amount of time in the units indicated by the provided {@link OWLTime} IRI
* @param iri - OWLTime IRI indicating the time unit of duration (not null)
* @return - the amount of time in milliseconds
* @throws IllegalArgumentException if provided {@link IRI} is not a valid, supported OWL-Time time unit.
*/
public static long getMillis(int duration, IRI iri) throws IllegalArgumentException {
Optional<ChronoUnit> unit = getChronoUnitFromURI(iri);
checkArgument(unit.isPresent(),
String.format("IRI %s does not indicate a valid OWLTime time unit. IRI must of be of type %s, %s, %s, %s, or %s .", iri,
SECONDS_URI, MINUTES_URI, HOURS_URI, DAYS_URI, WEEKS_URI));
return duration * unit.get().getDuration().toMillis();
}
代码示例来源:origin: org.neo4j/neo4j-random-values
private Duration nextDurationRaw()
{
return Duration.ofSeconds( nextLong( DAYS.getDuration().getSeconds() ), nextLong( NANOS_PER_SECOND ) );
}
代码示例来源:origin: io.debezium/debezium-core
/**
* Converts a number of time units to a duration in microseconds.
*
* @param years a number of years
* @param months a number of months
* @param days a number of days
* @param hours a number of hours
* @param minutes a number of minutes
* @param seconds a number of seconds
* @param micros a number of microseconds
* @param daysPerMonthAvg an optional value representing a days per month average; if null, the default duration
* from {@link ChronoUnit#MONTHS} is used.
* @return a {@link BigDecimal} value which contains the number of microseconds, never {@code null}
*/
public static double durationMicros(int years, int months, int days, int hours, int minutes, double seconds,
int micros, Double daysPerMonthAvg) {
if (daysPerMonthAvg == null) {
daysPerMonthAvg = (double) ChronoUnit.MONTHS.getDuration().toDays();
}
double numberOfDays = ((years * 12) + months) * daysPerMonthAvg + days;
double numberOfSeconds = (((numberOfDays * 24 + hours) * 60) + minutes) * 60 + seconds;
return numberOfSeconds * 1e6 + micros;
}
代码示例来源:origin: dCache/dcache
private static Optional<String> inUnits(Duration duration, ChronoUnit unit, String name)
{
Duration cutoff = unit.getDuration().multipliedBy(2);
if (duration.compareTo(cutoff) >= 0) {
return Optional.of(convert(duration, unit, name));
} else {
return Optional.empty();
}
}
代码示例来源:origin: dCache/dcache
private static String convert(Duration duration, ChronoUnit unit, String name)
{
double value = seconds(duration) / seconds(unit.getDuration());
return toThreeSigFig(value, 2000) + " " + name;
}
代码示例来源:origin: OpenGamma/Strata
} else {
eventsPerYear = -1;
double estimatedSecs = months * MONTHS.getDuration().getSeconds() + days * DAYS.getDuration().getSeconds();
eventsPerYearEstimate = YEARS.getDuration().getSeconds() / estimatedSecs;
代码示例来源:origin: com.github.lordrex34.config/commons-annotation-config
if (duration.getNano() % ChronoUnit.MILLIS.getDuration().getNano() >= 1)
result += (duration.getNano() % ChronoUnit.MILLIS.getDuration().getNano()) + "nanos";
内容来源于网络,如有侵权,请联系作者删除!