当前位置: 首页>>代码示例>>Java>>正文


Java TimeUnit.HOURS属性代码示例

本文整理汇总了Java中java.util.concurrent.TimeUnit.HOURS属性的典型用法代码示例。如果您正苦于以下问题:Java TimeUnit.HOURS属性的具体用法?Java TimeUnit.HOURS怎么用?Java TimeUnit.HOURS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.util.concurrent.TimeUnit的用法示例。


在下文中一共展示了TimeUnit.HOURS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toTimeUnit

/**
 * To time unit time unit.
 *
 * @param tu the tu
 * @return the time unit
 */
public static TimeUnit toTimeUnit(final ChronoUnit tu) {
    if (tu == null) {
        return null;
    }
    switch (tu) {
        case DAYS:
            return TimeUnit.DAYS;
        case HOURS:
            return TimeUnit.HOURS;
        case MINUTES:
            return TimeUnit.MINUTES;
        case SECONDS:
            return TimeUnit.SECONDS;
        case MICROS:
            return TimeUnit.MICROSECONDS;
        case MILLIS:
            return TimeUnit.MILLISECONDS;
        case NANOS:
            return TimeUnit.NANOSECONDS;
        default:
            throw new UnsupportedOperationException("Temporal unit is not supported");
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:29,代码来源:DateTimeUtils.java

示例2: serviceInit

@Override
protected void serviceInit(Configuration conf) throws Exception {
  int threadCount = conf.getInt(
      YarnConfiguration.RM_AMLAUNCHER_THREAD_COUNT,
      YarnConfiguration.DEFAULT_RM_AMLAUNCHER_THREAD_COUNT);
  ThreadFactory tf = new ThreadFactoryBuilder()
      .setNameFormat("ApplicationMasterLauncher #%d")
      .build();
  launcherPool = new ThreadPoolExecutor(threadCount, threadCount, 1,
      TimeUnit.HOURS, new LinkedBlockingQueue<Runnable>());
  launcherPool.setThreadFactory(tf);

  Configuration newConf = new YarnConfiguration(conf);
  newConf.setInt(CommonConfigurationKeysPublic.
          IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SOCKET_TIMEOUTS_KEY,
      conf.getInt(YarnConfiguration.RM_NODEMANAGER_CONNECT_RETIRES,
          YarnConfiguration.DEFAULT_RM_NODEMANAGER_CONNECT_RETIRES));
  setConfig(newConf);
  super.serviceInit(newConf);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:ApplicationMasterLauncher.java

示例3: toTimeUnit

/**
 * Convert a protocol buffer TimeUnit to a client TimeUnit
 * @param proto
 * @return the converted client TimeUnit
 */
public static TimeUnit toTimeUnit(final HBaseProtos.TimeUnit proto) {
  switch (proto) {
  case NANOSECONDS:
    return TimeUnit.NANOSECONDS;
  case MICROSECONDS:
    return TimeUnit.MICROSECONDS;
  case MILLISECONDS:
    return TimeUnit.MILLISECONDS;
  case SECONDS:
    return TimeUnit.SECONDS;
  case MINUTES:
    return TimeUnit.MINUTES;
  case HOURS:
    return TimeUnit.HOURS;
  case DAYS:
    return TimeUnit.DAYS;
  default:
    throw new RuntimeException("Invalid TimeUnit " + proto);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:ProtobufUtil.java

示例4: add

public void add(String key, Object value, long data, int timeType){//data为在redis存储有效时间
	Object type = null;
	switch (timeType) {
	case 0:
		type = TimeUnit.MINUTES;
		break;
	case 1:
		type = TimeUnit.HOURS;
		break;
	case 2:
		type = TimeUnit.DAYS;
	}
	redisTemplate.opsForValue().set(key, value, data, (TimeUnit)type);
}
 
开发者ID:xiachuanshou,项目名称:shop-manager,代码行数:14,代码来源:RedisDao.java

示例5: getTimeout

/**
 * Getter for the timeout
 * @return TimeOut
 */
public TimeOut getTimeout() {
    TimeOut timeOut = new TimeOut();
    Integer timeoutInt;
    if (timeoutSpinner.getValue() == "∞") {
        timeoutInt = 0;
    } else {
        timeoutInt = Integer.parseInt(timeoutSpinner.getValue().toString());
    }
    switch (timeoutUnit.getSelectedIndex()) {
        case 0:
            timeOut = new TimeOut(TimeUnit.SECONDS, timeoutInt.longValue());
            break;
        case 1:
            timeOut = new TimeOut(TimeUnit.MINUTES, timeoutInt.longValue());
            break;
        case 2:
            timeOut = new TimeOut(TimeUnit.HOURS, timeoutInt.longValue());
            break;
        case 3:
            timeOut = new TimeOut(TimeUnit.DAYS, timeoutInt.longValue());
            break;
        default:
            break;
    }
    return timeOut;
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:30,代码来源:TimeoutValueHandler.java

示例6: setUpClass

@BeforeClass
public static void setUpClass() {
    projectSaverLoader = new ProjectSaverLoader();
    ElectionTemplateHandler electionTemplateHandler = new ElectionTemplateHandler();
    ElectionTypeContainer inputType = electionTemplateHandler.getById(ElectionTypeContainer.ElectionInputTypeIds.WEIGHTED_APPROVAL);
    ElectionTypeContainer outputType = electionTemplateHandler.getStandardResult();

    ElectionDescription electionDescription = new ElectionDescription("testDescription", inputType, outputType, 2);
    ArrayList<String> code = new ArrayList<String>();
    code.add("sdfgokdffg");
    code.add("sdkofgdfg");
    electionDescription.setCode(code);

    FormalPropertiesDescription pre = new FormalPropertiesDescription("CODECODEOCDEOASD ASDAOSDASOD ;;; ;ASODAOSD");
    FormalPropertiesDescription post = new FormalPropertiesDescription("CODECODEOCDEOASD ASDAOSDASOD ;;; ;ASODAOSD");
    SymbolicVariableList list = new SymbolicVariableList();
    list.addSymbolicVariable("voter1", new InternalTypeContainer(InternalTypeRep.VOTER));
    list.addSymbolicVariable("voter2", new InternalTypeContainer(InternalTypeRep.VOTER));
    list.addSymbolicVariable("candidate", new InternalTypeContainer(InternalTypeRep.CANDIDATE));
    list.addSymbolicVariable("seat", new InternalTypeContainer(InternalTypeRep.SEAT));
    PreAndPostConditionsDescription description1 = new PreAndPostConditionsDescription("description1",
            pre, post, list);
    PreAndPostConditionsDescription description2 = new PreAndPostConditionsDescription("description2",
            pre, post, list);

    PLModel plModel = new PLModel();
    plModel.initialize();
    PropertyItem propertyItem = new PropertyItem(description1, true, true);
    PropertyItem propertyItem2 = new PropertyItem(description2, false, false);
    plModel.addDescription(propertyItem);
    plModel.addDescription(propertyItem2);
    ElectionCheckParameter electionCheckParameter = new ElectionCheckParameter(Arrays.asList(new Integer[]{1, 2}),
            Arrays.asList(new Integer[]{1, 2}), Arrays.asList(new Integer[]{1, 2}), new TimeOut(TimeUnit.HOURS,
            (long) 3.2),4, "-- unwind 6");
    project = new Project(electionCheckParameter, plModel, electionDescription, "TestProject");
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:36,代码来源:ProjectSaverLoaderTest.java

示例7: niceTimeRounded

public static long niceTimeRounded ( final long value )
{
    final TimeUnit tu;

    if ( value >= TimeUnit.DAYS.toMillis ( 1 ) )
    {
        tu = TimeUnit.DAYS;
    }
    else if ( value >= TimeUnit.HOURS.toMillis ( 1 ) )
    {
        tu = TimeUnit.HOURS;
    }
    else if ( value >= TimeUnit.MINUTES.toMillis ( 1 ) )
    {
        tu = TimeUnit.MINUTES;
    }
    else if ( value >= TimeUnit.SECONDS.toMillis ( 1 ) )
    {
        tu = TimeUnit.SECONDS;
    }
    else
    {
        tu = TimeUnit.MILLISECONDS;
    }

    double v = (double)value / (double)tu.toMillis ( 1 );
    v = niceNum ( v, true );
    return (long) ( v * tu.toMillis ( 1 ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:29,代码来源:Helper.java

示例8: parse

@Override
public void parse(CacheBuilderSpec spec, String key, String value) {
  checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
  try {
    char lastChar = value.charAt(value.length() - 1);
    TimeUnit timeUnit;
    switch (lastChar) {
      case 'd':
        timeUnit = TimeUnit.DAYS;
        break;
      case 'h':
        timeUnit = TimeUnit.HOURS;
        break;
      case 'm':
        timeUnit = TimeUnit.MINUTES;
        break;
      case 's':
        timeUnit = TimeUnit.SECONDS;
        break;
      default:
        throw new IllegalArgumentException(
            format(
                "key %s invalid format.  was %s, must end with one of [dDhHmMsS]", key, value));
    }

    long duration = Long.parseLong(value.substring(0, value.length() - 1));
    parseDuration(spec, duration, timeUnit);
  } catch (NumberFormatException e) {
    throw new IllegalArgumentException(
        format("key %s value set to %s, must be integer", key, value));
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:32,代码来源:CacheBuilderSpec.java

示例9: catchAllAndLogWithThrottle

private Runnable catchAllAndLogWithThrottle(Runnable r) {
    LogThrottle throttle = new LogThrottle(1, TimeUnit.HOURS);
    return () -> {
        try {
            r.run();
        } catch (RuntimeException e) {
            if (throttle.throttle(e)) {
                log.error("Execution failed: " + e);
            } else {
                log.error("Execution failed", e);
            }
        }
    };
}
 
开发者ID:OasisDigital,项目名称:nges,代码行数:14,代码来源:EventStoreStatusHeartbeat.java

示例10: serializeTimeUnit_resultJsonHasTimeUnit

@Test
public void serializeTimeUnit_resultJsonHasTimeUnit() throws IOException {
  //given
  TimeStringFormat timeStringFormat = new TimeStringFormat(TimeUnit.HOURS);
  //when
  JsonNode actualObj = serializeTimeStringFormat(timeStringFormat);
  //then
  Assertions.assertThat(actualObj.has("unit")).isTrue();
  Assertions.assertThat(actualObj.get("unit").asText()).isEqualTo("HOURS");
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:10,代码来源:TimeStringFormatSerializerTest.java

示例11:

@LifeCache(duration = 1, timeUnit = TimeUnit.HOURS)
Observable<Results> getDataResults(Observable<Results> oResults, DynamicKeyGroup pageAndType, EvictDynamicKeyGroup refresh);
 
开发者ID:SirLYC,项目名称:Android-Gank-Share,代码行数:2,代码来源:CacheProviders.java

示例12: setUpClass

@BeforeClass
public static void setUpClass() {
    timeOut = new TimeOut(TimeUnit.HOURS, (long) 3.2);
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:4,代码来源:TimeOutSaverLoaderTest.java

示例13: setUpClass

@BeforeClass
public static void setUpClass() {
    electionCheckParameter = new ElectionCheckParameter(Arrays.asList(new Integer[]{1, 2}),
            Arrays.asList(new Integer[]{1, 2}), Arrays.asList(new Integer[]{1, 2}), new TimeOut(TimeUnit.HOURS,
            (long) 3.2),4, "-- unwind 6");
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:6,代码来源:ElectionCheckParameterSaverLoaderTest.java

示例14: timeValueHours

public static TimeValue timeValueHours(long hours) {
    return new TimeValue(hours, TimeUnit.HOURS);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:3,代码来源:TimeValue.java

示例15: TipiThreadPoolExecutor

public TipiThreadPoolExecutor() {
	super(0, Integer.MAX_VALUE, 1, TimeUnit.HOURS, new SynchronousQueue<Runnable>());
}
 
开发者ID:shared-vd,项目名称:tipi-engine,代码行数:3,代码来源:TipiThreadPoolExecutor.java


注:本文中的java.util.concurrent.TimeUnit.HOURS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。