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


Java TimeUnit.toSeconds方法代码示例

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


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

示例1: listFeaturesSinceInner

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
private FeatureCollection listFeaturesSinceInner(String nsKey, long timestamp,
    TimeUnit timeUnit) {
  try {
    long ts = timeUnit.toSeconds(timestamp);

    String url = UriBuilder.builder(baseUri)
        .path(PATH_FEATURES)
        .path(nsKey)
        .query(PARAM_SINCE, ts + "")
        .buildString();

    return toFeatureCollection(getRequest(nsKey, url).body().string());
  } catch (IOException e) {
    throw new FeatureException(Problem.localProblem(e.getMessage(), ""), e);
  }
}
 
开发者ID:dehora,项目名称:outland,代码行数:17,代码来源:FeatureResourceReal.java

示例2: ttl

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
@Override
public void ttl(int lifetime, TimeUnit unit) {
	int seconds = (int) unit.toSeconds(lifetime);
	TTLValue ttlValue = new TTLValue(seconds);
	HttpResponse httpResponse = httpclient.post(HttpAPI.TTL, ttlValue.toJSON());
	ResultResponse resultResponse = ResultResponse.simplify(httpResponse, this.httpCompress);
	HttpStatus httpStatus = resultResponse.getHttpStatus();
	switch (httpStatus) {
	case ServerSuccess:
		return;
	case ServerNotSupport:
		throw new HttpServerNotSupportException(resultResponse);
	case ServerError:
		throw new HttpServerErrorException(resultResponse);
	default:
		throw new HttpUnknowStatusException(resultResponse);
	}
}
 
开发者ID:aliyun,项目名称:HiTSDB-Client,代码行数:19,代码来源:HiTSDBClient.java

示例3: formatTimeInterval

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
private static String formatTimeInterval(long time, String format){
	TimeUnit c = TimeUnit.MILLISECONDS;
	
	long S = c.toSeconds(time);
	long M = c.toMinutes(time);
	long H = c.toHours(time);
	long D = c.toDays(time);

	long s = c.toSeconds(time - TimeUnit.MINUTES.toMillis(M));
	long m = c.toMinutes(time - TimeUnit.HOURS.toMillis(H));
	long h = c.toHours(time - TimeUnit.DAYS.toMillis(D));
	
	String r = format;
	r = r.replace("%S", "" + S);
	r = r.replace("%M", "" + M);
	r = r.replace("%H", "" + H);
	r = r.replace("%D", "" + D);
	r = r.replace("%s", (s > 9 ? "" : "0") + s);
	r = r.replace("%m", (m > 9 ? "" : "0") + m);
	r = r.replace("%h", (h > 9 ? "" : "0") + h);
	
	return r;
}
 
开发者ID:TBlueF,项目名称:RottenFood,代码行数:24,代码来源:RottenFood.java

示例4: printEventMetric

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
/**
 * Prints an Event Metric.
 *
 * @param operationStr the string with the intent operation to print
 * @param eventMetric the Event Metric to print
 */
private void printEventMetric(String operationStr,
                              EventMetric eventMetric) {
    Gauge<Long> gauge = eventMetric.lastEventTimestampGauge();
    Meter meter = eventMetric.eventRateMeter();
    TimeUnit rateUnit = TimeUnit.SECONDS;
    double rateFactor = rateUnit.toSeconds(1);

    // Print the Gauge
    print(FORMAT_GAUGE, operationStr, gauge.getValue());

    // Print the Meter
    print(FORMAT_METER, operationStr, meter.getCount(),
          meter.getMeanRate() * rateFactor,
          meter.getOneMinuteRate() * rateFactor,
          meter.getFiveMinuteRate() * rateFactor,
          meter.getFifteenMinuteRate() * rateFactor);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:IntentEventsMetricsCommand.java

示例5: formatTimeInterval

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
/**
 * Convert from an amount of time to a string in the format xxd:hh:mm:ss
 * @param amount interval that needs to be formatted
 * @param timeUnit the unit of the interval
 * @return a formatted string representing the input interval
 */
public static String formatTimeInterval(long amount, TimeUnit timeUnit) {
	long totSeconds = timeUnit.toSeconds(amount);
	long seconds = totSeconds % 60;
	long totMinutes = timeUnit.toMinutes(amount);
	long minutes = totMinutes % 60;
	long totHours = timeUnit.toHours(amount);
	long hours = totHours % 24;
	long days = timeUnit.toDays(amount);
	String result = String.format("%02d:%02d", minutes, seconds);
	if (hours+days>0) {
		result = String.format("%02d:", hours) + result;
		if (days>0) {
			result = String.format("%dd:", days) + result;
		}
	}
	return result;
}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:24,代码来源:YadaUtil.java

示例6: JmxMeter

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
private JmxMeter(Metered metric, ObjectName objectName, TimeUnit rateUnit)
{
    super(objectName);
    this.metric = metric;
    this.rateFactor = rateUnit.toSeconds(1);
    this.rateUnit = "events/" + calculateRateUnit(rateUnit);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:8,代码来源:CassandraMetricsRegistry.java

示例7: toSeconds

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
protected long toSeconds(long timeout, TimeUnit unit) {
    long seconds = unit.toSeconds(timeout);
    if (timeout != 0 && seconds == 0) {
        seconds = 1;
    }
    return seconds;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:8,代码来源:RedissonQueue.java

示例8: DropwizardTransformer

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
public DropwizardTransformer(final Map<String, String> baseTags,
                             final DropwizardMeasurementParser parser,
                             final boolean groupCounters,
                             final boolean groupGauges,
                             final TimeUnit rateUnit,
                             final TimeUnit durationUnit) {
  this.baseTags = baseTags;
  this.parser = parser;
  this.groupCounters = groupCounters;
  this.groupGauges = groupGauges;
  this.rateFactor = rateUnit.toSeconds(1);
  this.durationFactor = durationUnit.toNanos(1);
}
 
开发者ID:kickstarter,项目名称:dropwizard-influxdb-reporter,代码行数:14,代码来源:DropwizardTransformer.java

示例9: durationToTimeString

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
public static String durationToTimeString(long duration) {
	TimeUnit scale = TimeUnit.MILLISECONDS;
	long days = scale.toDays(duration);
	duration -= TimeUnit.DAYS.toMillis(days);
	long hours = scale.toHours(duration);
	duration -= TimeUnit.HOURS.toMillis(hours);
	long minutes = scale.toMinutes(duration);
	duration -= TimeUnit.MINUTES.toMillis(minutes);
	long seconds = scale.toSeconds(duration);
	return String.format("%d days, %d hours, %d minutes, %d seconds", days, hours, minutes, seconds);
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:12,代码来源:Utils.java

示例10: TimerSerializer

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
private TimerSerializer(TimeUnit rateUnit, TimeUnit durationUnit, String timestampFieldname) {
    super(JsonTimer.class);
    this.timestampFieldname = timestampFieldname;
    this.rateUnit = calculateRateUnit(rateUnit, "calls");
    this.rateFactor = rateUnit.toSeconds(1);
    this.durationUnit = durationUnit.toString().toLowerCase(Locale.US);
    this.durationFactor = 1.0 / durationUnit.toNanos(1);
}
 
开发者ID:oneops,项目名称:oneops,代码行数:9,代码来源:MetricsElasticsearchModule.java

示例11: toTicks

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
public static long toTicks(TimeUnit unit, long duration) {
    return unit.toSeconds(duration) * 20;
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:4,代码来源:AzureAPI.java

示例12: getCacheTime

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
public Long getCacheTime(String url){
    if (mUrlMap!=null){
        Long type = mUrlMap.get(url);
        if (type!=null){
            return type;
        }
    }
    for (Map serviceMethodCache:mVector) {

        for (Object entry:serviceMethodCache.keySet()){
            Object o = serviceMethodCache.get(entry);
            try {

                if (mUrlAragsMap.containsKey(url)){
                    Object[] args = (Object[]) mUrlAragsMap.get(url);
                    String reqUrl =  buildRequestUrl(o,args);
                    if (reqUrl.equals(url)){
                        Method m = (Method) entry;
                        Cache cache =  m.getAnnotation(Cache.class);
                        if (cache!=null){
                            TimeUnit timeUnit =  mDefaultTimeUnit;
                            if (cache.timeUnit() != TimeUnit.NANOSECONDS){
                                timeUnit = cache.timeUnit();
                            }
                            long t = mDefaultTime;
                            if (cache.time() != -1){
                                t = cache.time();
                            }
                            long tm =  timeUnit.toSeconds(t);
                            getUrlMap().put(url, tm);
                            return tm;
                        }else{
                            getUrlMap().put(url, 0L);
                            return 0L;
                        }
                    }
                }
            } catch (Exception e) {
                LogUtil.l(e);
            }
        }
    }
    getUrlMap().put(url, 0L);
    return 0L;
}
 
开发者ID:yale8848,项目名称:RetrofitCache,代码行数:46,代码来源:RetrofitCache.java

示例13: FollowersOnlyEvent

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
public FollowersOnlyEvent(Channel channel, long time, TimeUnit timeUnit) {
	super(channel, time > -1);
	this.time = timeUnit.toSeconds(time);
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:5,代码来源:FollowersOnlyEvent.java

示例14: toTicks

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
private long toTicks(long amount, TimeUnit timeUnit) {
    return timeUnit.toSeconds(amount) / 20;
}
 
开发者ID:shawlaf,项目名称:Banmanager,代码行数:4,代码来源:BanmanagerServer.java

示例15: realtime

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
public Builder realtime(long time, TimeUnit unit) {
	this.realTimeSeconds = (int) unit.toSeconds(time);
	return this;
}
 
开发者ID:aliyun,项目名称:HiTSDB-Client,代码行数:5,代码来源:SubQuery.java


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