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

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

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

ChronoUnit.name介绍

暂无

代码示例

代码示例来源:origin: google/error-prone

static Optional<ChronoUnit> getInvalidChronoUnit(
  MethodInvocationTree tree, EnumSet<ChronoUnit> invalidUnits) {
 Optional<String> constant = getEnumName(Iterables.getOnlyElement(tree.getArguments()));
 if (constant.isPresent()) {
  for (ChronoUnit invalidTemporalUnit : invalidUnits) {
   if (constant.get().equals(invalidTemporalUnit.name())) {
    return Optional.of(invalidTemporalUnit);
   }
  }
 }
 return Optional.empty();
}

代码示例来源:origin: jtablesaw/tablesaw

default LongColumn difference(DateTimeColumn column2, ChronoUnit unit) {
  LongColumn newColumn = LongColumn.create(name() + " - " + column2.name() + "[" + unit.name() + "]");
  for (int r = 0; r < size(); r++) {
    if (this.isMissing(r) || column2.isMissing(r)) {
      newColumn.appendMissing();
    } else {
      long c1 = this.getLongInternal(r);
      long c2 = column2.getLongInternal(r);
      LocalDateTime value1 = asLocalDateTime(c1);
      LocalDateTime value2 = asLocalDateTime(c2);
      if (value1 != null && value2 != null) {
        newColumn.append(unit.between(value1, value2));
      } else {
        newColumn.appendMissing();
      }
    }
  }
  return newColumn;
}

代码示例来源:origin: jtablesaw/tablesaw

default IntColumn difference(TimeColumn column2, ChronoUnit unit) {
  IntColumn newColumn = IntColumn.create(name() + " - " + column2.name() + "[" + unit.name() + "]");
  for (int r = 0; r < size(); r++) {
    int c1 = this.getIntInternal(r);
    int c2 = column2.getIntInternal(r);
    if (TimeColumn.valueIsMissing(c1) || TimeColumn.valueIsMissing(c2)) {
      newColumn.append(IntColumnType.missingValueIndicator());
    } else {
      LocalTime value1 = PackedLocalTime.asLocalTime(c1);
      LocalTime value2 = PackedLocalTime.asLocalTime(c2);
      if (value1 != null && value2 != null) {
        newColumn.append((int) unit.between(value1, value2));
      } else {
        newColumn.appendMissing();
      }
    }
  }
  return newColumn;
}

代码示例来源:origin: jtablesaw/tablesaw

IntColumn newColumn = IntColumn.create(name() + " - " + end.name() + "[" + unit.name() + "]");

代码示例来源:origin: ChronixDB/chronix.server

@Override
public String[] getArguments() {
  return new String[]{"timeSpan=" + timeSpan, "unit=" + unit.name()};
}

代码示例来源:origin: ChronixDB/chronix.server

@Override
public String[] getArguments() {
  return new String[]{"amount=" + amount, "unit=" + unit.name().toUpperCase()};
}

代码示例来源:origin: Krillsson/sys-API

public void purge(int olderThan, ChronoUnit unit) {
    LocalDateTime maxAge = clock.now().minus(olderThan, unit);
    Set<HistoryEntry> toBeRemoved = new HashSet<>();
    for (HistoryEntry historyEntry : history) {
      if (historyEntry.date.isBefore(maxAge)) {
        toBeRemoved.add(historyEntry);
      }
    }

    LOGGER.trace("Purging {} entries older than {} {}", toBeRemoved.size(), olderThan, unit.name());
    toBeRemoved.forEach(history::remove);
  }
}

代码示例来源:origin: zalando/nakadi

@Override
public void describeTo(final Description description) {
  description.appendText(MessageFormat.format("date is within {0} {1} to date: {2}",
      period, unit.name(), compareDate.toString()));
}

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

this.updateStatement.setString(index++, cachedHTML.getChronoUnit().name());
  this.updateStatement.setLong(index++, cachedHTML.getLastChange());
  this.updateStatement.setLong(index++, cachedHTML.getLastChecked());
} else {
  this.saveStatement.setString(index++, id);
  this.saveStatement.setString(index++, cachedHTML.getChronoUnit().name());
  this.saveStatement.setLong(index++, cachedHTML.getLastChange());
  this.saveStatement.setLong(index++, cachedHTML.getLastChecked());

代码示例来源:origin: espertechinc/esper

private CodegenExpression codegenLDTZDT(CodegenExpression val, Class type) {
    CodegenExpression chronoUnit = enumValue(ChronoUnit.class, fieldName.getChronoUnit().name());
    if (code == ApacheCommonsDateUtils.MODIFY_TRUNCATE) {
      return exprDotMethod(val, "truncatedTo", chronoUnit);
    } else if (code == ApacheCommonsDateUtils.MODIFY_CEILING) {
      return exprDotMethodChain(val).add("plus", constant(1), chronoUnit).add("truncatedTo", chronoUnit);
    } else {
      throw new EPException("Round-half operation not supported for " + type.getSimpleName());
    }
  }
}

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

public static void serialize(final List<StateDuration> durations, 
    final ResourceList<org.smartrplace.tools.profiles.prefs.model.StateDuration> baseResource, final ResourceTransaction trans) {
  trans.create(baseResource);
  final String baseName = baseResource.getName();
  for (int i = 0; i<durations.size(); i++) {
    final StateDuration obj = durations.get(i);
    final org.smartrplace.tools.profiles.prefs.model.StateDuration sub = baseResource.getSubResource(baseName + "_" + i, org.smartrplace.tools.profiles.prefs.model.StateDuration.class);
    trans.create(sub);
    trans.setInteger(sub.duration(), obj.getDuration());
    trans.setString(sub.stateId(), obj.state.id());
    trans.setString(sub.timeUnit(), obj.unit.name());
  }
}

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

/**
 * {@inheritDoc}
 */
@Override
public Document to(CachedHTML cachedHTML) {
  Document document = new Document();
  document.put(ID, cachedHTML.getID());
  document.put(CHRONO_UNIT, cachedHTML.getChronoUnit().name());
  document.put(LAST_CHANGE, cachedHTML.getLastChange());
  document.put(LAST_CHECKED, cachedHTML.getLastChecked());
  document.put(URL, cachedHTML.getURL());
  document.put(HTML, cachedHTML.getHTML());
  return document;
}

代码示例来源:origin: tech.tablesaw/tablesaw-core

default LongColumn difference(DateTimeColumn column2, ChronoUnit unit) {
  LongColumn newColumn = LongColumn.create(name() + " - " + column2.name() + "[" + unit.name() + "]");
  for (int r = 0; r < size(); r++) {
    if (this.isMissing(r) || column2.isMissing(r)) {
      newColumn.appendMissing();
    } else {
      long c1 = this.getLongInternal(r);
      long c2 = column2.getLongInternal(r);
      LocalDateTime value1 = asLocalDateTime(c1);
      LocalDateTime value2 = asLocalDateTime(c2);
      if (value1 != null && value2 != null) {
        newColumn.append(unit.between(value1, value2));
      } else {
        newColumn.appendMissing();
      }
    }
  }
  return newColumn;
}

代码示例来源:origin: tech.tablesaw/tablesaw-core

default IntColumn difference(TimeColumn column2, ChronoUnit unit) {
  IntColumn newColumn = IntColumn.create(name() + " - " + column2.name() + "[" + unit.name() + "]");
  for (int r = 0; r < size(); r++) {
    int c1 = this.getIntInternal(r);
    int c2 = column2.getIntInternal(r);
    if (TimeColumn.valueIsMissing(c1) || TimeColumn.valueIsMissing(c2)) {
      newColumn.append(IntColumnType.missingValueIndicator());
    } else {
      LocalTime value1 = PackedLocalTime.asLocalTime(c1);
      LocalTime value2 = PackedLocalTime.asLocalTime(c2);
      if (value1 != null && value2 != null) {
        newColumn.append((int) unit.between(value1, value2));
      } else {
        newColumn.appendMissing();
      }
    }
  }
  return newColumn;
}

代码示例来源:origin: tech.tablesaw/tablesaw-core

IntColumn newColumn = IntColumn.create(name() + " - " + end.name() + "[" + unit.name() + "]");

相关文章