java.time.temporal.ChronoUnit.valueOf()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中java.time.temporal.ChronoUnit.valueOf()方法的一些代码示例,展示了ChronoUnit.valueOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ChronoUnit.valueOf()方法的具体详情如下:
包路径:java.time.temporal.ChronoUnit
类名称:ChronoUnit
方法名:valueOf

ChronoUnit.valueOf介绍

暂无

代码示例

代码示例来源:origin: oracle/helidon

@Override
  public ChronoUnit unit() {
    LookupResult<Timeout> lookupResult = lookupAnnotation(Timeout.class);
    final String override = getParamOverride("unit", lookupResult.getType());
    return override != null ? ChronoUnit.valueOf(override) : lookupResult.getAnnotation().unit();
  }
}

代码示例来源:origin: oracle/helidon

@Override
public ChronoUnit durationUnit() {
  LookupResult<Retry> lookupResult = lookupAnnotation(Retry.class);
  final String override = getParamOverride("durationUnit", lookupResult.getType());
  return override != null ? ChronoUnit.valueOf(override) : lookupResult.getAnnotation().durationUnit();
}

代码示例来源:origin: oracle/helidon

@Override
public ChronoUnit jitterDelayUnit() {
  LookupResult<Retry> lookupResult = lookupAnnotation(Retry.class);
  final String override = getParamOverride("jitterDelayUnit", lookupResult.getType());
  return override != null ? ChronoUnit.valueOf(override) : lookupResult.getAnnotation().jitterDelayUnit();
}

代码示例来源:origin: oracle/helidon

@Override
public ChronoUnit delayUnit() {
  LookupResult<CircuitBreaker> lookupResult = lookupAnnotation(CircuitBreaker.class);
  final String override = getParamOverride("delayUnit", lookupResult.getType());
  return override != null ? ChronoUnit.valueOf(override) : lookupResult.getAnnotation().delayUnit();
}

代码示例来源:origin: oracle/helidon

@Override
public ChronoUnit delayUnit() {
  LookupResult<Retry> lookupResult = lookupAnnotation(Retry.class);
  final String override = getParamOverride("delayUnit", lookupResult.getType());
  return override != null ? ChronoUnit.valueOf(override) : lookupResult.getAnnotation().delayUnit();
}

代码示例来源:origin: yahoo/egads

+ "e.g. MINUTES OR HOURS");
windowUnits = ChronoUnit.valueOf(temp.toUpperCase()); 
      + "e.g. MINUTES OR HOURS");
intervalUnits = ChronoUnit.valueOf(temp.toUpperCase());
      + "required, e.g. MINUTES OR HOURS");
windowDistanceIntervalUnits = ChronoUnit.valueOf(temp.toUpperCase());

代码示例来源:origin: kieker-monitoring/kieker

public DependencyGraphConfiguration(final String importDirectory, final String timeUnitOfRecods,
    final String exportDirectory) {
  this(new File(importDirectory), ChronoUnit.valueOf(timeUnitOfRecods), new File(exportDirectory));
}

代码示例来源: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: com.github.jmgilmour/parker-sql-core

/**
 * {@inheritDoc}
 * 
 * This will use the previously initialized {@link PreparedStatement}s.
 * Using the get statement, we read from the database and convert the result
 * into a {@link CachedHTML}.
 * 
 */
@Override
public CachedHTML get(String id) {
  CachedHTML cachedHTML = null;
  try {
    this.getStatement.setString(1, id);
    ResultSet resultSet = this.getStatement.executeQuery();
    while (resultSet.next()) {
      cachedHTML = new CachedHTML();
      cachedHTML.setID(resultSet.getString("id"));
      cachedHTML.setChronoUnit(ChronoUnit.valueOf(resultSet.getString("chronoUnit")));
      cachedHTML.setLastChange(resultSet.getLong("lastChange"));
      cachedHTML.setLastChecked(resultSet.getLong("lastChecked"));
      cachedHTML.setURL(resultSet.getString("url"));
      cachedHTML.setHTML(resultSet.getString("html"));
    }
  } catch (SQLException e) {
    e.printStackTrace();
  }
  return cachedHTML;
}

代码示例来源:origin: org.ogema.eval/timeseries-eval-base

@Override
public EvaluationInstance newEvaluation(String id, EvaluationProvider provider, List<EvaluationInput> input,
    List<ResultType> requestedResults, Collection<ConfigurationInstance> configurations) {
  final EvaluationInstance instance = provider.newEvaluation(id, input, requestedResults, configurations);
  Long timestep = null;
  if (configurations != null) {
    timestep = configurations.stream()
      .filter(cfg -> cfg.getConfigurationType() == TimestepConfiguration.INSTANCE)
      .map(cfg -> {
        GenericDurationConfiguration durationCfg = (GenericDurationConfiguration) cfg;
        final long d = durationCfg.getDuration();
        final String unit0 = durationCfg.getUnit();
        TemporalUnit unit = ChronoUnit.MILLIS;
        try {
          unit = ChronoUnit.valueOf(unit0.toUpperCase());
        } catch (Exception e) {}
        final long totalDuration = unit.getDuration().toMillis() * d;
        return totalDuration;
      }).findAny().orElse(null);
  } else {
    timestep = provider.requestedUpdateInterval();
  }
  
  final Evaluation eval = new Evaluation(EvaluationUtils.getMultiTimeSeriesIterator(input,
      requestedResults, configurations, instance, timestep), instance);
  instance.addListener(eval);
  Executors.newSingleThreadExecutor().submit(eval);
  return instance;
}

代码示例来源:origin: org.smartrplace.tools/profile-preferences

public static StateDuration deserialize(org.smartrplace.tools.profiles.prefs.model.StateDuration resource, final ProfileTemplate template) {
  final State state = template.states().stream()
      .filter(st -> resource.stateId().getValue().equals(st.id()))
      .findAny().orElse(null);
  if (state == null)
    return null;
  final int dur = resource.duration().getValue();
  if (dur <= 0)
    return null;
  try {
    final ChronoUnit unit = ChronoUnit.valueOf(resource.timeUnit().getValue());
    return new StateDuration(state, dur, unit);
  } catch (IllegalArgumentException e) {
    return null;
  }
}

代码示例来源:origin: org.smartrplace.logging/fendodb-core

@Descriptor("Delete all data in a given FendoDb instance before some timestamp")
public boolean deleteDataOlderThan(
    @Descriptor("Database path, relative to rundir or absolute")
    final String path,
    @Descriptor("The duration.")
    final int amount,
    @Descriptor("The time unit, see ChronoUnit class. Examples: 'MINUTES', 'HOURS', 'DAYS', ...")
    final String unit
    ) throws IOException {
  try (final CloseableDataRecorder slots = factory.getExistingInstance(Paths.get(path))) {
    if (slots == null) {
      System.out.println("No database found under the specified path " + path);
      return false;
    }
    if (amount <= 0) {
      System.out.println("Time amount must be positive, got " +amount );
      return false;
    }
    final ChronoUnit cunit;
    try {
      cunit = ChronoUnit.valueOf(unit.toUpperCase());
    } catch (IllegalArgumentException e) {
      System.out.println("Time unit " + unit + " not found.");
      return false;
    }
    final Duration duration = Duration.of(amount, cunit);
    return slots.deleteDataOlderThan(duration);
  }
}

代码示例来源:origin: com.github.jmgilmour/parker-mongodb

/**
 * {@inheritDoc}
 */
@Override
public CachedHTML from(Document document) {
  if (document == null) {
    return null;
  }
  CachedHTML cachedHTML = new CachedHTML();
  cachedHTML.setID(document.getString(ID));
  cachedHTML.setChronoUnit(ChronoUnit.valueOf(document.getString(CHRONO_UNIT)));
  cachedHTML.setLastChange(document.getLong(LAST_CHANGE));
  cachedHTML.setLastChecked(document.getLong(LAST_CHECKED));
  cachedHTML.setURL(document.getString(URL));
  cachedHTML.setHTML(document.getString(HTML));
  return cachedHTML;
}

相关文章