Example usage for org.joda.time Duration standardSeconds

List of usage examples for org.joda.time Duration standardSeconds

Introduction

In this page you can find the example usage for org.joda.time Duration standardSeconds.

Prototype

public static Duration standardSeconds(long seconds) 

Source Link

Document

Create a duration with the specified number of seconds assuming that there are the standard number of milliseconds in a second.

Usage

From source file:com.google.errorprone.bugpatterns.testdata.ObjectToStringNegativeCases.java

License:Apache License

public void overridePresentInAbstractClassInHierarchy(Duration durationArg) {
    String unusedString = Duration.standardSeconds(86400).toString();
    System.out.println("test joda string " + Duration.standardSeconds(86400));

    unusedString = durationArg.toString();
    System.out.println("test joda string " + durationArg);
}

From source file:com.linagora.scheduling.DummyTask.java

License:Open Source License

DummyTask() {
    this(Duration.standardSeconds(1));
}

From source file:com.mastfrog.acteur.auth.AuthenticateBasicActeur.java

License:Open Source License

@Benchmark(value = "tarpittedClients", publish = Kind.CALL_COUNT)
void delayResponse(int badCount, Settings settings) {
    Duration delayResponse = Duration
            .standardSeconds(badCount * settings.getInt(SETTINGS_KEY_TARPIT_DELAY_SECONDS, 1));
    response().setDelay(delayResponse);//from w w w  .j  ava2s  . c o m
}

From source file:com.mastfrog.acteur.util.CacheControl.java

License:Open Source License

public boolean isExpired() {
    if (contains(CacheControlTypes.no_cache) || contains(CacheControlTypes.no_store)) {
        return true;
    }//from  ww  w.j a va 2  s . co  m
    Long maxAgeSeconds = get(CacheControlTypes.max_age);
    if (maxAgeSeconds != null) {
        Duration dur = new Duration(new DateTime(), creationTime);
        Duration target = Duration.standardSeconds(maxAgeSeconds);
        if (dur.isLongerThan(target)) {
            return true;
        }
    }
    return false;
}

From source file:com.mastfrog.giulius.settings.etcd.EtcdModule.java

License:Open Source License

@Override
protected void configure() {
    try {//w w  w .  jav a  2  s  .co m
        String url = settings.getString(SETTINGS_KEY_ETCD_URL, DEFAULT_ETCD_URL);

        Duration refresh = Duration.standardSeconds(settings.getLong(SETTINGS_KEY_ETCD_REFRESH_INTERVAL_SECONDS,
                DEFAULT_ETCD_REFRESH_INTERVAL_SECONDS));
        bind(Duration.class).annotatedWith(Names.named(GUICE_BINDING_ETCD_REFRESH_INTERVAL))
                .toInstance(refresh);
        bind(ScheduledExecutorService.class).annotatedWith(Names.named(GUICE_BINDING_ETCD_REFRESH_THREAD_POOL))
                .toInstance(Executors.newSingleThreadScheduledExecutor());
        bind(ThreadPoolAndHttpClientShutdown.class).asEagerSingleton();
        //            CloseableHttpAsyncClient httpclient = buildDefaultHttpClient();
        //            bind(CloseableHttpAsyncClient.class).toInstance(httpclient);

        HttpClient httpClient = HttpClient.builder().maxChunkSize(512).noCompression().maxInitialLineLength(255)
                .followRedirects().threadCount(1).dontSend100Continue().build();
        bind(HttpClient.class).annotatedWith(Names.named(GUICE_BINDING_HTTP_CLIENT)).toInstance(httpClient);

        List<EtcdClient> clients = new ArrayList<>();
        for (String u : url.split(",")) {
            clients.add(new EtcdClient(new URI(u), httpClient));
        }
        EtcdClient[] arr = clients.toArray(new EtcdClient[0]);
        MetaEtcdClient meta = new MetaEtcdClient(settings, arr);
        bind(EtcdClient.class).toProvider(meta);
        bind(MetaEtcdClient.class).toInstance(meta);
        bind(EtcdClient[].class).toInstance(arr);
    } catch (URISyntaxException ex) {
        Exceptions.chuck(ex);
    }
}

From source file:com.mastfrog.giulius.settings.etcd.MetaEtcdClient.java

License:Open Source License

@Inject
public MetaEtcdClient(Settings settings, EtcdClient... clients) {
    if (clients == null || clients.length == 0) {
        throw new IllegalArgumentException("No clients: " + clients);
    }// www.jav  a  2 s . c om
    maxRetries = settings.getInt(SETTINGS_KEY_MAX_RETRIES, DEFAULT_MAX_RETRIES);
    Duration failWindow = Duration
            .standardSeconds(settings.getInt(SETTINGS_KEY_FAIL_WINDOW, DEFAULT_FAIL_WINDOW));
    List<Entry> e = new ArrayList<>();
    int maxFails = settings.getInt(SETTINGS_KEY_MAX_FAILS_TO_DISABLE, DEFAULT_MAX_FAILS_TO_DISABLE);

    for (EtcdClient client : clients) {
        e.add(new Entry(client, failWindow, maxFails));
    }
    entries = ImmutableList.copyOf(e);
}

From source file:com.peertopark.java.dates.Dates.java

License:Apache License

public static long getDaysFromSeconds(long seconds) {
    return Duration.standardSeconds(seconds).getStandardDays();
}

From source file:com.peertopark.java.dates.Dates.java

License:Apache License

/**
 * Get minutes from seconds//  ww w  .  java 2 s. c o m
 *
 * @param seconds
 * @return long
 */
public static long getMinutesFromSeconds(long seconds) {
    return Duration.standardSeconds(seconds).getStandardMinutes();
}

From source file:com.peertopark.java.dates.Dates.java

License:Apache License

public static long getHoursFromSeconds(long seconds) {
    return Duration.standardSeconds(seconds).getStandardHours();
}

From source file:com.predic8.membrane.core.interceptor.apimanagement.quota.AMQuota.java

License:Apache License

private void fillPolicyQuotas() {
    policyQuotas.clear();/*from w w  w  . j  a v  a 2  s .  c om*/
    for (Policy policy : amc.getPolicies().values()) {
        String name = policy.getName();
        long quotaSize = policy.getQuota().getSize();
        int interval = policy.getQuota().getInterval();
        HashSet<String> services = new HashSet<String>(policy.getServiceProxies());
        PolicyQuota pq = new PolicyQuota();
        pq.setName(name);
        pq.setSize(quotaSize);
        pq.setInterval(Duration.standardSeconds(interval));
        pq.incrementNextCleanup();
        pq.setServices(services);
        policyQuotas.put(name, pq);
    }
}