ch.qos.logback.core.util.Duration.valueOf()方法的使用及代码示例

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

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

Duration.valueOf介绍

暂无

代码示例

代码示例来源:origin: ch.qos.logback/logback-classic

private Duration getDuration(String scanAttrib, String scanPeriodAttrib) {
  Duration duration = null;
  if (!OptionHelper.isEmpty(scanPeriodAttrib)) {
    try {
      duration = Duration.valueOf(scanPeriodAttrib);
    } catch (NumberFormatException nfe) {
      addError("Error while converting [" + scanAttrib + "] to long", nfe);
    }
  }
  return duration;
}

代码示例来源:origin: camunda/camunda-bpm-platform

void processScanAttrib(InterpretationContext ic, Attributes attributes) {
 String scanAttrib = ic.subst(attributes.getValue(SCAN_ATTR));
 if (!OptionHelper.isEmpty(scanAttrib)
     && !"false".equalsIgnoreCase(scanAttrib)) {
  ReconfigureOnChangeFilter rocf = new ReconfigureOnChangeFilter();
  rocf.setContext(context);
  String scanPeriodAttrib = ic.subst(attributes.getValue(SCAN_PERIOD_ATTR));
  if (!OptionHelper.isEmpty(scanPeriodAttrib)) {
   try {
    Duration duration = Duration.valueOf(scanPeriodAttrib);
    rocf.setRefreshPeriod(duration.getMilliseconds());
    addInfo("Setting ReconfigureOnChangeFilter scanning period to "
        + duration);
   } catch (NumberFormatException nfe) {
    addError("Error while converting [" + scanAttrib + "] to long", nfe);
   }
  }
  rocf.start();
  LoggerContext lc = (LoggerContext) context;
  addInfo("Adding ReconfigureOnChangeFilter as a turbo filter");
  lc.addTurboFilter(rocf);
 }
}

代码示例来源:origin: tony19/logback-android

/**
 * Set the maximum history in time duration of records to keep
 *
 * @param maxHistory
 *                max history in time duration (e.g., "2 days")
 */
public void setMaxHistory(String maxHistory) {
 this.maxHistory = Duration.valueOf(maxHistory);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

private Duration getDuration(String scanAttrib, String scanPeriodAttrib) {
  Duration duration = null;
  if (!OptionHelper.isEmpty(scanPeriodAttrib)) {
    try {
      duration = Duration.valueOf(scanPeriodAttrib);
    } catch (NumberFormatException nfe) {
      addError("Error while converting [" + scanAttrib + "] to long", nfe);
    }
  }
  return duration;
}

代码示例来源:origin: Nextdoor/bender

private Duration getDuration(String scanAttrib, String scanPeriodAttrib) {
  Duration duration = null;
  if (!OptionHelper.isEmpty(scanPeriodAttrib)) {
    try {
      duration = Duration.valueOf(scanPeriodAttrib);
    } catch (NumberFormatException nfe) {
      addError("Error while converting [" + scanAttrib + "] to long", nfe);
    }
  }
  return duration;
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

private Duration getDuration(String scanAttrib, String scanPeriodAttrib) {
  Duration duration = null;
  if (!OptionHelper.isEmpty(scanPeriodAttrib)) {
    try {
      duration = Duration.valueOf(scanPeriodAttrib);
    } catch (NumberFormatException nfe) {
      addError("Error while converting [" + scanAttrib + "] to long", nfe);
    }
  }
  return duration;
}

代码示例来源:origin: tony19/logback-android

private Duration getDurationOfScanPeriodAttribute(String scanPeriodAttrib, Duration defaultDuration) {
 Duration duration = null;
 if (!OptionHelper.isEmpty(scanPeriodAttrib)) {
  Exception ex = null;
  try {
   duration = Duration.valueOf(scanPeriodAttrib);
  } catch (IllegalArgumentException e) {
   ex = e;
  } catch (IllegalStateException e) {
   ex = e;
  }
  if (ex != null) {
   addWarn("Failed to parse 'scanPeriod' attribute ["+scanPeriodAttrib+"]", ex);
  }
 }
 if (duration == null) {
  addInfo("No 'scanPeriod' specified. Defaulting to " + defaultDuration.toString());
  duration = defaultDuration;
 }
 return duration;
}

代码示例来源:origin: tony19/logback-android

Duration d = Duration.valueOf("12");
assertEquals(12, d.getMilliseconds());
Duration d = Duration.valueOf("159 milli");
assertEquals(159, d.getMilliseconds());
Duration d = Duration.valueOf("15 millis");
assertEquals(15, d.getMilliseconds());
Duration d = Duration.valueOf("8 milliseconds");
assertEquals(8, d.getMilliseconds());
Duration d = Duration.valueOf("10.7 millisecond");
assertEquals(10, d.getMilliseconds());
Duration d = Duration.valueOf("10 SECOnds");
assertEquals(10 * 1000, d.getMilliseconds());
Duration d = Duration.valueOf("12seconde");
assertEquals(12 * 1000, d.getMilliseconds());
Duration d = Duration.valueOf("14 SECONDES");
assertEquals(14 * 1000, d.getMilliseconds());
Duration d = Duration.valueOf("12second");
assertEquals(12 * 1000, d.getMilliseconds());
Duration d = Duration.valueOf("10.7 seconds");
assertEquals(10700, d.getMilliseconds());

代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand

void processScanAttrib(Attributes attributes) {
 String scanAttrib = attributes.getValue(SCAN_ATTR);
 if (!OptionHelper.isEmpty(scanAttrib)
   && !"false".equalsIgnoreCase(scanAttrib)) {
  ReconfigureOnChangeFilter rocf = new ReconfigureOnChangeFilter();
  rocf.setContext(context);
  String scanPeriodAttrib = attributes.getValue(SCAN_PERIOD_ATTR);
  if (!OptionHelper.isEmpty(scanPeriodAttrib)) {
   try {
    Duration duration = Duration.valueOf(scanPeriodAttrib);
    rocf.setRefreshPeriod(duration.getMilliseconds());
    addInfo("Setting ReconfigureOnChangeFilter scanning period to "
      + duration);
   } catch (NumberFormatException nfe) {
    addError("Error while converting [" + scanAttrib + "] to long", nfe);
   }
  }
  rocf.start();
  LoggerContext lc = (LoggerContext) context;
  addInfo("Adding ReconfigureOnChangeFilter as a turbo filter");
  lc.addTurboFilter(rocf);
 }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/ch.qos.logback.classic

void processScanAttrib(InterpretationContext ic, Attributes attributes) {
 String scanAttrib = ic.subst(attributes.getValue(SCAN_ATTR));
 if (!OptionHelper.isEmpty(scanAttrib)
     && !"false".equalsIgnoreCase(scanAttrib)) {
  ReconfigureOnChangeFilter rocf = new ReconfigureOnChangeFilter();
  rocf.setContext(context);
  String scanPeriodAttrib = ic.subst(attributes.getValue(SCAN_PERIOD_ATTR));
  if (!OptionHelper.isEmpty(scanPeriodAttrib)) {
   try {
    Duration duration = Duration.valueOf(scanPeriodAttrib);
    rocf.setRefreshPeriod(duration.getMilliseconds());
    addInfo("Setting ReconfigureOnChangeFilter scanning period to "
        + duration);
   } catch (NumberFormatException nfe) {
    addError("Error while converting [" + scanAttrib + "] to long", nfe);
   }
  }
  rocf.start();
  LoggerContext lc = (LoggerContext) context;
  addInfo("Adding ReconfigureOnChangeFilter as a turbo filter");
  lc.addTurboFilter(rocf);
 }
}

相关文章