List of usage examples for java.util.concurrent TimeUnit HOURS
TimeUnit HOURS
To view the source code for java.util.concurrent TimeUnit HOURS.
Click Source Link
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. * // ww w . j av a2 s.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.xdi.oxd.server.license.LicenseUpdateService.java
private void scheduleUpdatePinger() { final ScheduledExecutorService executorService = Executors .newSingleThreadScheduledExecutor(CoreUtils.daemonThreadFactory()); executorService.scheduleAtFixedRate(new Runnable() { @Override//ww w . j a v a 2s . c o m public void run() { updateLicenseFromServer(); } }, 1, conf.getLicenseCheckPeriodInHours(), TimeUnit.HOURS); }
From source file:org.blocks4j.reconf.client.validation.ConnectionSettingsValidator.java
private static void checkTimeUnit(ConnectionSettings arg, Collection<String> errors) { if (arg.getTimeUnit() == null) { errors.add(msg.get("timeUnit.null")); return;/*from ww w. j av a 2 s . co m*/ } if (!EnumSet.of(TimeUnit.SECONDS, TimeUnit.MINUTES, TimeUnit.HOURS, TimeUnit.DAYS) .contains(arg.getTimeUnit())) { errors.add(msg.get("timeUnit.null")); } }
From source file:org.jdal.text.PeriodFormatter.java
/** * {@inheritDoc}/* w ww. j av a 2 s . c om*/ */ 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:org.wso2.carbon.integrator.core.handler.EndpointHolder.java
private EndpointHolder() { //retry interval 2 hour long interval = 2; ScheduledExecutorService globalExecutorService = Executors.newSingleThreadScheduledExecutor(); globalExecutorService.scheduleAtFixedRate(this, interval, interval, TimeUnit.HOURS); }
From source file:springfox.documentation.schema.CachingModelProvider.java
@Autowired public CachingModelProvider(@Qualifier("default") final ModelProvider delegate) { this.delegate = delegate; cache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(24, TimeUnit.HOURS) .build(new CacheLoader<ModelContext, Optional<Model>>() { public Optional<Model> load(ModelContext key) { return delegate.modelFor(key); }//from w w w . jav a 2 s . c o m }); }
From source file:springfox.documentation.spring.web.scanners.CachingOperationReader.java
@Autowired public CachingOperationReader(@Qualifier("default") final OperationReader delegate) { cache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(24, TimeUnit.HOURS) .build(new CacheLoader<Equivalence.Wrapper<RequestMappingContext>, List<Operation>>() { public List<Operation> load(Equivalence.Wrapper<RequestMappingContext> key) { return delegate.read(key.get()); }/*from ww w .jav a 2s . co m*/ }); }
From source file:springfox.documentation.schema.CachingModelDependencyProvider.java
@Autowired public CachingModelDependencyProvider(@Qualifier("default") final ModelDependencyProvider delegate) { cache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(24, TimeUnit.HOURS) .build(new CacheLoader<ModelContext, Set<ResolvedType>>() { public Set<ResolvedType> load(ModelContext key) { return delegate.dependentModels(key); }/* w w w . j a va 2 s . co m*/ }); }
From source file:org.eclipse.skalli.core.rest.admin.StatisticsQueryTest.java
@Test public void testPeriod() throws Exception { assertPeriodQuery(null, 1, TimeUnit.DAYS); assertPeriodQuery("", 1, TimeUnit.DAYS); assertPeriodQuery("0", 1, TimeUnit.DAYS); assertPeriodQuery("1d", 1, TimeUnit.DAYS); assertPeriodQuery("27D", 27, TimeUnit.DAYS); assertPeriodQuery("3", 3, TimeUnit.DAYS); assertPeriodQuery("4711", 4711, TimeUnit.DAYS); assertPeriodQuery("d", 1, TimeUnit.DAYS); assertPeriodQuery("D", 1, TimeUnit.DAYS); assertPeriodQuery("5h", 5, TimeUnit.HOURS); assertPeriodQuery("15h", 15, TimeUnit.HOURS); assertPeriodQuery("h", 1, TimeUnit.HOURS); assertPeriodQuery("H", 1, TimeUnit.HOURS); assertPeriodQuery("4711m", 4711, TimeUnit.MINUTES); assertPeriodQuery("3M", 3, TimeUnit.MINUTES); assertPeriodQuery("m", 1, TimeUnit.MINUTES); assertPeriodQuery("M", 1, TimeUnit.MINUTES); }