Example usage for java.util.concurrent TimeUnit DAYS

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

Introduction

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

Prototype

TimeUnit DAYS

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

Click Source Link

Document

Time unit representing twenty four hours.

Usage

From source file:com.hpcloud.util.Duration.java

public static Duration days(long count) {
    return new Duration(count, TimeUnit.DAYS);
}

From source file:de.knightsoftnet.mtwidgets.client.ui.widget.AbstractPhoneNumberRestSuggestBox.java

/**
 * default constructor./* ww  w  .  j  av a2  s . c o  m*/
 */
public AbstractPhoneNumberRestSuggestBox(final SuggestOracle poracle) {
    super(poracle);
    this.callback = new AsyncCallback<ValueWithPos<String>>() {

        @Override
        public void onFailure(final Throwable pcaught) {
            GWT.log(pcaught.getMessage(), pcaught);
        }

        @Override
        public void onSuccess(final ValueWithPos<String> presponse) {
            if (presponse != null && StringUtils.isNotEmpty(presponse.getValue())) {
                AbstractPhoneNumberRestSuggestBox.this.setTextWithPos(presponse);
            }
        }

    };
    this.cache = CacheBuilder.newBuilder().maximumSize(10000).expireAfterWrite(10, TimeUnit.DAYS)
            .build(new CacheLoader<ValueWithPosAndCountry<String>, FutureResult<ValueWithPos<String>>>() {

                @Override
                public FutureResult<ValueWithPos<String>> load(final ValueWithPosAndCountry<String> pkey) {
                    final FutureResult<ValueWithPos<String>> result = new FutureResult<>();
                    result.addCallback(AbstractPhoneNumberRestSuggestBox.this.callback);
                    try {
                        AbstractPhoneNumberRestSuggestBox.this.formatValue(pkey, result);
                    } catch (final ExecutionException e) {
                        GWT.log(e.getMessage(), e);
                    }
                    return result;
                }
            });
}

From source file:com.linkedin.pinot.query.selection.SelectionQueriesSVTest.java

@BeforeClass
public void setup() throws Exception {
    FileUtils.deleteQuietly(INDEX_DIR);//from  w w w  . j a v  a2 s  . c om

    // Get resource file path.
    URL resource = getClass().getClassLoader().getResource(AVRO_DATA);
    Assert.assertNotNull(resource);
    String filePath = resource.getFile();

    // Build the index segment.
    SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns(
            new File(filePath), INDEX_DIR, "time_day", TimeUnit.DAYS, "testTable");
    SegmentIndexCreationDriver driver = new SegmentIndexCreationDriverImpl();
    driver.init(config);
    driver.build();

    // Load the index segment.
    File indexSegmentDir = new File(INDEX_DIR, driver.getSegmentName());
    _indexSegment = ColumnarSegmentLoader.load(indexSegmentDir, ReadMode.heap);

    // Initialize the data source map.
    _dataSourceMap = new HashMap<>();
    _dataSourceMap.put("column11", _indexSegment.getDataSource("column11"));
    _dataSourceMap.put("column12", _indexSegment.getDataSource("column12"));
    _dataSourceMap.put("column13", _indexSegment.getDataSource("column13"));
    _dataSourceMap.put("met_impressionCount", _indexSegment.getDataSource("met_impressionCount"));

    // Build the selection ONLY query.
    _selectionOnlyQuery = new Selection();
    _selectionOnlyQuery.setSelectionColumns(Arrays.asList("column12", "column11", "met_impressionCount"));
    _selectionOnlyQuery.setSize(10);

    // Build the selection ORDER BY query.
    _selectionOrderByQuery = new Selection();
    _selectionOrderByQuery.setSelectionColumns(Arrays.asList("column12", "column11", "met_impressionCount"));
    _selectionOrderByQuery.setSize(10);
    SelectionSort selectionSort1 = new SelectionSort();
    selectionSort1.setColumn("column13");
    SelectionSort selectionSort2 = new SelectionSort();
    selectionSort2.setColumn("column11");
    _selectionOrderByQuery.setSelectionSortSequence(Arrays.asList(selectionSort1, selectionSort2));
}

From source file:com.linkedin.pinot.query.selection.SelectionQueriesMVTest.java

@BeforeClass
public void setup() throws Exception {
    FileUtils.deleteQuietly(INDEX_DIR);//w  ww.  ja v a  2  s  .c  om

    // Get resource file path.
    URL resource = getClass().getClassLoader().getResource(AVRO_DATA);
    Assert.assertNotNull(resource);
    String filePath = resource.getFile();

    // Build the index segment.
    SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns(
            new File(filePath), INDEX_DIR, "daysSinceEpoch", TimeUnit.DAYS, "testTable");
    SegmentIndexCreationDriver driver = new SegmentIndexCreationDriverImpl();
    driver.init(config);
    driver.build();

    // Load the index segment.
    File indexSegmentDir = new File(INDEX_DIR, driver.getSegmentName());
    _indexSegment = ColumnarSegmentLoader.load(indexSegmentDir, ReadMode.heap);

    // Initialize the data source map.
    _dataSourceMap = new HashMap<>();
    _dataSourceMap.put("column1", _indexSegment.getDataSource("column1"));
    _dataSourceMap.put("column2", _indexSegment.getDataSource("column2"));
    _dataSourceMap.put("column6", _indexSegment.getDataSource("column6"));
    _dataSourceMap.put("count", _indexSegment.getDataSource("count"));

    // Build the selection ONLY query.
    _selectionOnlyQuery = new Selection();
    _selectionOnlyQuery.setSelectionColumns(Arrays.asList("column6", "column1", "count"));
    _selectionOnlyQuery.setSize(10);

    // Build the selection ORDER BY query.
    _selectionOrderByQuery = new Selection();
    _selectionOrderByQuery.setSelectionColumns(Arrays.asList("column6", "column1", "count"));
    _selectionOrderByQuery.setSize(10);
    SelectionSort selectionSort1 = new SelectionSort();
    selectionSort1.setColumn("column2");
    SelectionSort selectionSort2 = new SelectionSort();
    selectionSort2.setColumn("column1");
    _selectionOrderByQuery.setSelectionSortSequence(Arrays.asList(selectionSort1, selectionSort2));
}

From source file:ar.com.zauber.commons.mom.test.CxfStyleUnitTest.java

public HashMap<String, Object> newMap() {
    return new HashMap<String, Object>() {
        {// ww  w.  j  a  v a  2  s .  c  o m
            put("stringProperty", "hola");
            put("enumProperty", TimeUnit.DAYS);
            put("listProperty", Arrays.asList(10, 0));
            put("arrayProperty", Arrays.asList(10, 0));
            put("otherListProperty", Arrays.<Map<String, Object>>asList(new HashMap<String, Object>() {
                {
                    put("cant", 10);
                    put("name", "foo");
                }
            }));
        }
    };
}

From source file:org.pentaho.di.www.cache.CarteStatusCache.java

private CarteStatusCache() {
    period = Integer.parseInt(Const.getEnvironmentVariable("CARTE_CLEAR_PERIOD", "1"));
    timeUnit = TimeUnit.valueOf(Const.getEnvironmentVariable("CARTE_CLEAR_TIMEUNIT", "DAYS"));

    removeService.scheduleAtFixedRate(this::clear, 1, 1, TimeUnit.DAYS);
}

From source file:com.l2jfree.gameserver.model.skills.effects.templates.EffectTemplate.java

public EffectTemplate(StatsSet set, L2Skill skill) {
    name = set.getString("name");
    lambda = set.getDouble("val", 0);
    count = Math.max(1, set.getInteger("count", 1));

    int time = set.getInteger("time", 1) * skill.getTimeMulti();

    if (time < 0) {
        if (count == 1)
            period = (int) TimeUnit.DAYS.toSeconds(10); // 'infinite' - still in integer range, even in msec
        else//from  w  w w.  jav a  2  s.  c  o  m
            throw new IllegalStateException("Invalid count (> 1) for effect with infinite duration!");
    } else
        period = Math.max(1, time);

    if (set.contains("abnormal")) {
        final String abnormal = set.getString("abnormal").toLowerCase();
        abnormalEffect = AbnormalEffect.getByName(abnormal).getMask();
    } else
        abnormalEffect = 0;

    if (set.contains("special")) {
        final String special = set.getString("special").toLowerCase();
        specialEffect = SpecialEffect.getByName(special).getMask();
    } else
        specialEffect = 0;

    stackTypes = set.getString("stackType", skill.generateUniqueStackType()).split(";");
    stackOrder = set.getFloat("stackOrder", skill.generateStackOrder());

    for (int i = 0; i < stackTypes.length; i++)
        stackTypes[i] = stackTypes[i].intern();

    if (stackTypes.length > 1 && stackOrder != 99)
        throw new IllegalStateException("'stackOrder' should be 99 for merged effects!");

    showIcon = set.getInteger("noicon", 0) == 0;

    effectPower = set.getDouble("effectPower", -1);
    effectType = set.getEnum("effectType", L2SkillType.class, null);

    if ((effectPower == -1) != (effectType == null))
        throw new IllegalArgumentException("Missing effectType/effectPower for effect: " + name);

    triggeredSkill = TriggeredSkill.parse(set);
    chanceCondition = ChanceCondition.parse(set);

    if ("ChanceSkillTrigger".equals(name)) {
        if (triggeredSkill == null)
            throw new NoSuchElementException(name + " requires proper TriggeredSkill parameters!");

        if (chanceCondition == null)
            throw new NoSuchElementException(name + " requires proper ChanceCondition parameters!");
    } else {
        if (triggeredSkill != null)
            throw new NoSuchElementException(name + " can't have TriggeredSkill parameters!");

        if (chanceCondition != null)
            throw new NoSuchElementException(name + " can't have ChanceCondition parameters!");
    }

    try {
        final StringBuilder sb = new StringBuilder();
        sb.append(IEffectMarker.class.getPackage().getName());
        sb.append(".Effect");
        sb.append(name);
        final Class<?> clazz = Class.forName(sb.toString());

        _constructor = clazz.getConstructor(Env.class, EffectTemplate.class);

        Constructor<?> stolenConstructor = null;
        try {
            stolenConstructor = clazz.getConstructor(Env.class, L2Effect.class);
        } catch (NoSuchMethodException e) {
        }
        _stolenConstructor = stolenConstructor;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:docs.security.RememberMeSecurityConfigurationTests.java

@Test
public void authenticateWhenSpringSessionRememberMeEnabledThenCookieMaxAgeAndSessionExpirationSet()
        throws Exception {
    // @formatter:off
    MvcResult result = this.mockMvc.perform(formLogin()).andReturn();
    // @formatter:on

    Cookie cookie = result.getResponse().getCookie("SESSION");
    assertThat(cookie.getMaxAge()).isEqualTo(Integer.MAX_VALUE);
    T session = this.sessions.getSession(cookie.getValue());
    assertThat(session.getMaxInactiveIntervalInSeconds()).isEqualTo((int) TimeUnit.DAYS.toSeconds(30));

}

From source file:org.thiesen.jiffs.jobs.preprocessor.Preprocessor.java

@Override
public void execute() {
    final Iterable<StoryDBO> unprocessed = _storyDAO.findWithoutPreprocesing();

    System.out.println("Preprocessing " + Iterables.size(unprocessed) + " stories");

    for (final StoryDBO story : unprocessed) {
        EXECUTOR.submit(new Runnable() {

            @Override/*from  w  w w .  ja  va2s.c o m*/
            public void run() {
                preproecessText(story);
            }
        });

    }

    EXECUTOR.shutdown();

    try {
        EXECUTOR.awaitTermination(1, TimeUnit.DAYS);
    } catch (InterruptedException e) {
        Thread.interrupted();

    }

}

From source file:emily.util.YTUtil.java

/**
 * Time until the next google api reset happens (Midnight PT), or 9am GMT
 *
 * @return formatted string, eg. "10 minutes form now"
 *//*  w ww  .  j av a2s  . c o m*/
public static String nextApiResetTime() {
    Calendar c = Calendar.getInstance();
    c.add(Calendar.DAY_OF_MONTH, 0);
    c.set(Calendar.HOUR_OF_DAY, 9);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    return TimeUtil.getRelativeTime(
            (System.currentTimeMillis()
                    + (c.getTimeInMillis() - System.currentTimeMillis()) % TimeUnit.DAYS.toMillis(1)) / 1000L,
            false);
}