Example usage for java.util.concurrent TimeUnit MINUTES

List of usage examples for java.util.concurrent TimeUnit MINUTES

Introduction

In this page you can find the example usage for java.util.concurrent TimeUnit MINUTES.

Prototype

TimeUnit MINUTES

To view the source code for java.util.concurrent TimeUnit MINUTES.

Click Source Link

Document

Time unit representing sixty seconds.

Usage

From source file:com.groupon.odo.tests.TestServer.TestHttpProxyContainer.java

@Bean
public EmbeddedServletContainerFactory servletContainer() {
    TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
    MockService config = MockService.getInstance();
    factory.setPort(config.getPort());/*  ww w. j  a  v  a2 s  . c o m*/
    factory.setSessionTimeout(10, TimeUnit.MINUTES);
    factory.addContextCustomizers(new TomcatContextCustomizer() {
        @Override
        public void customize(Context context) {
            JarScanner jarScanner = new JarScanner() {
                @Override
                public void scan(ServletContext arg0, ClassLoader arg1, JarScannerCallback arg2,
                        Set<String> arg3) {
                }
            };
            context.setJarScanner(jarScanner);
        }
    });
    return factory;
}

From source file:com.qpark.eip.core.spring.statistics.impl.AppUserStatisticsChannelAdapter.java

/**
 * @param millis//w w w  .  j  av  a  2  s.  c  o  m
 * @return the duration in 000:00:00.000 format.
 */
static String getDuration(final long millis) {
    String hmss = String.format("%03d:%02d:%02d.%03d", TimeUnit.MILLISECONDS.toHours(millis),
            TimeUnit.MILLISECONDS.toMinutes(millis)
                    - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
            TimeUnit.MILLISECONDS.toSeconds(millis)
                    - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)),
            TimeUnit.MILLISECONDS.toMillis(millis)
                    - TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(millis)));
    return hmss;
}

From source file:org.zenoss.zep.dao.impl.ElapsedTime.java

public static String formatElapsed(final long elapsedMillis) {
    final long hr = TimeUnit.MILLISECONDS.toHours(elapsedMillis);
    final long min = TimeUnit.MILLISECONDS.toMinutes(elapsedMillis - TimeUnit.HOURS.toMillis(hr));
    final long sec = TimeUnit.MILLISECONDS
            .toSeconds(elapsedMillis - TimeUnit.HOURS.toMillis(hr) - TimeUnit.MINUTES.toMillis(min));
    final long ms = TimeUnit.MILLISECONDS.toMillis(elapsedMillis - TimeUnit.HOURS.toMillis(hr)
            - TimeUnit.MINUTES.toMillis(min) - TimeUnit.SECONDS.toMillis(sec));
    return String.format("%02dh:%02dm:%02d.%03ds", hr, min, sec, ms);
}

From source file:net.easymfne.factionsdb.Util.java

/**
 * Convert a time in milliseconds to a user-friendly String format.
 * //  www  .j  a va 2s  .  c  o m
 * @param time
 *            Number of milliseconds
 * @return User-friendly String
 */
public static String generateTimeString(long time) {
    List<String> timeStrings = new ArrayList<String>();
    long d = TimeUnit.MILLISECONDS.toDays(time);
    time -= TimeUnit.DAYS.toMillis(d);
    long h = TimeUnit.MILLISECONDS.toHours(time);
    time -= TimeUnit.HOURS.toMillis(h);
    long m = TimeUnit.MILLISECONDS.toMinutes(time);
    time -= TimeUnit.MINUTES.toMillis(m);
    long s = TimeUnit.MILLISECONDS.toSeconds(time);

    if (d > 0) {
        timeStrings.add(d + (d == 1 ? " day" : " days"));
    }
    if (h > 0) {
        timeStrings.add(h + (h == 1 ? " hour" : " hours"));
    }
    if (m > 0) {
        timeStrings.add(m + (m == 1 ? " minute" : " minutes"));
    }
    if (s > 0 || timeStrings.size() < 1) {
        timeStrings.add(s + (s == 1 ? " second" : " seconds"));
    }

    return StringUtils.join(timeStrings, ", ");
}

From source file:org.jdal.text.PeriodFormatter.java

/**
 * {@inheritDoc}/*from  ww w. jav  a 2  s .  c  o m*/
 */
public String print(Number number, Locale locale) {
    long period = number.longValue();
    long days = TimeUnit.MILLISECONDS.toDays(period);
    long left = period - TimeUnit.DAYS.toMillis(days);
    long hours = TimeUnit.MILLISECONDS.toHours(left);
    left -= TimeUnit.HOURS.toMillis(hours);
    long minutes = TimeUnit.MILLISECONDS.toMinutes(left);
    left -= TimeUnit.MINUTES.toMillis(minutes);
    long seconds = TimeUnit.MILLISECONDS.toSeconds(left);

    StringBuilder sb = new StringBuilder();

    if (days != 0)
        append(sb, days, DAYS);

    if (hours != 0)
        append(sb, hours, HOURS);

    if (minutes != 0)
        append(sb, minutes, MINUTES);

    if (seconds != 0)
        append(sb, seconds, SECONDS);

    return sb.toString();
}

From source file:eu.codesketch.adam.rest.infrastructure.config.Application.java

@Bean
public CacheManager cacheManager() {
    GuavaCacheManager manager = new GuavaCacheManager("nodes", "info", "containers");
    CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.MINUTES)
            .maximumSize(25);//from   w w  w.ja  va 2 s . co m
    manager.setCacheBuilder(builder);
    return manager;
}

From source file:nblair.pipeline.PipelineThreadPoolExecutor.java

/**
 * Calls the superclass' constructor passing in the queueCapacity,
 * 1 Minute keep alive time, a bounded {@link LinkedBlockingQueue},
 * a {@link CustomizableThreadFactory}, and an {@link OfferRejectedExecutionHandler}.
 * // w  ww.  j a  va  2  s  . c  o  m
 * @see LinkedBlockingQueue
 * @see ThreadPoolExecutor
 * @see CustomizableThreadFactory
 * @param queueCapacity the capacity of the work queue
 * @param namePrefix the thread name prefix
 */
public PipelineThreadPoolExecutor(int queueCapacity, String namePrefix) {
    super(queueCapacity, queueCapacity, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>(queueCapacity),
            new CustomizableThreadFactory(namePrefix), new OfferRejectedExecutionHandler());
}

From source file:com.comphenix.protocol.events.PacketMetadata.java

private static void createCache() {
    META_CACHE = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build();
}

From source file:com.rationaldevelopers.oss.service.CacheService.java

public void update(SimpleItem simpleItem) {
    if (simpleItem != null && simpleItem.getSid() != null) {
        cache.put(simpleItem.getSid(), simpleItem, 2, TimeUnit.MINUTES);
    }/*from w w  w  .  jav a 2  s.  c om*/
}

From source file:com.groupon.odo.tests.TestServer.TestHttpsProxyContainer.java

@Bean
public EmbeddedServletContainerFactory servletContainer() throws Exception {
    TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
    MockService config = MockService.getInstance();
    factory.setPort(config.getPort());/* w ww . j  ava 2  s.c  o  m*/
    factory.setSessionTimeout(10, TimeUnit.MINUTES);
    factory.addContextCustomizers(new TomcatContextCustomizer() {
        @Override
        public void customize(Context context) {
            JarScanner jarScanner = new JarScanner() {
                @Override
                public void scan(ServletContext arg0, ClassLoader arg1, JarScannerCallback arg2,
                        Set<String> arg3) {
                }
            };
            context.setJarScanner(jarScanner);
        }
    });

    // extract keystores to temp file
    // the keystore needs to be in the filesystem and not just on the classpath
    // this ensures that it gets unpacked from the jar/war
    final File keyStore = com.groupon.odo.proxylib.Utils.copyResourceToLocalFile("tomcat.ks", "tomcat.ks");

    // Add HTTPS customization to connector
    factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
        @Override
        public void customize(Connector connector) {
            MockService config = MockService.getInstance();
            connector.setPort(config.getPort());
            connector.setSecure(true);
            Http11NioProtocol proto = (Http11NioProtocol) connector.getProtocolHandler();
            proto.setSSLEnabled(true);
            connector.setScheme("https");
            connector.setAttribute("keystorePass", "changeit");
            connector.setAttribute("keystoreFile", keyStore.getAbsolutePath());
            connector.setAttribute("clientAuth", "false");
            connector.setAttribute("sslProtocol", "TLS");
            connector.setAttribute("sslEnabled", true);
        }
    });

    return factory;
}