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


Java TimeUnit.DAYS属性代码示例

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


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

示例1: provideForShouldNotBeSerialized

@DataProvider(name = SHOULD_NOT_BE_SERIALIZED_PROVIDER)
public Object[][] provideForShouldNotBeSerialized() {
    Date time = Calendar.getInstance().getTime();
    return new Object[][]{
        {TimeUnit.DAYS},
        {0},
        {(short) 0},
        {(byte) 0},
        {0L},
        {0.0D},
        {0.0F},
        {'c'},
        {"string"},
        {time},
        {null}
    };
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:17,代码来源:JDBCKeyValueMapperUnitTest.java

示例2: updateMinutes

private void updateMinutes() {
    Integer minutes = null;

    try {
        Integer value = Integer.valueOf(valueTxt.getText());

        if (unitCombo.getValue() == TimeUnit.DAYS) {
            minutes = Math.toIntExact(TimeUnit.DAYS.toMinutes(value));
        } else if (unitCombo.getValue() == TimeUnit.HOURS) {
            minutes = Math.toIntExact(TimeUnit.HOURS.toMinutes(value));
        } else {
            minutes = value;
        }
    } catch (NumberFormatException e) {
        // DO nothing
    }

    reminder.setMinutes(minutes);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:19,代码来源:GoogleEntryDetailsView.java

示例3: calculateRadiusOfGyrationOverTime

/**
 * Calculates a list of progressing radius of gyration numbers based on time
 * unit given. Currently, day is supported.
 * 
 * @param traces
 *            location traces of an individual
 * @param unit
 *            spatial distance unit
 * @param timeUnit
 *            time unit for radius of gyration calculation. Day is supported.
 * @return an array of calculated radius of gyration.
 * @throws TimeUnitNotSupportedException 
 */
public double[] calculateRadiusOfGyrationOverTime(List<LocationTrace> traces, 
		SpatialDistanceUnit unit, TimeUnit timeUnit) throws TimeUnitNotSupportedException{
	if (timeUnit != TimeUnit.DAYS){
		throw new TimeUnitNotSupportedException(
				timeUnit + " is not supported. Please pass days as time unit.");
	}
	LocationTraceHelper traceHelper = new LocationTraceHelper();
	List<LocationTrace> selectedTraces;
	LocalDateTime firstTraceTime = traces.get(0).getLocalTime().minusMinutes(1);
	LocalDateTime lastTraceTime = traces.get(traces.size()-1).getLocalTime();
	double[] rogResults;
	LocalDateTime curentEndDate;
	
	int numberOfDays = Days.daysBetween(firstTraceTime, lastTraceTime).getDays();
	
	rogResults = new double[numberOfDays-1];
	
	for(int i=1; i < numberOfDays; i++ ){
		curentEndDate = firstTraceTime.plusDays(i).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
		selectedTraces = traceHelper.selectBetweenDates(traces, firstTraceTime, curentEndDate);
		rogResults[i-1] = calculateRadiusOfGyration(selectedTraces);
	}
	
	return rogResults;
}
 
开发者ID:hamdikavak,项目名称:human-mobility-modeling-utilities,代码行数:38,代码来源:RadiusOfGyration.java

示例4: testCompareUnits

public void testCompareUnits() {
    long number = randomNonNegativeLong();
    TimeUnit randomUnit = randomValueOtherThan(TimeUnit.DAYS, ()->randomFrom(TimeUnit.values()));
    TimeValue firstValue = new TimeValue(number, randomUnit);
    TimeValue secondValue = new TimeValue(number, TimeUnit.DAYS);
    assertTrue(firstValue.compareTo(secondValue) < 0);
    assertTrue(secondValue.compareTo(firstValue) > 0);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:TimeValueTests.java

示例5: niceTimeRounded

public static long niceTimeRounded ( final long value )
{
    final TimeUnit tu;

    if ( value >= TimeUnit.DAYS.toMillis ( 1 ) )
    {
        tu = TimeUnit.DAYS;
    }
    else if ( value >= TimeUnit.HOURS.toMillis ( 1 ) )
    {
        tu = TimeUnit.HOURS;
    }
    else if ( value >= TimeUnit.MINUTES.toMillis ( 1 ) )
    {
        tu = TimeUnit.MINUTES;
    }
    else if ( value >= TimeUnit.SECONDS.toMillis ( 1 ) )
    {
        tu = TimeUnit.SECONDS;
    }
    else
    {
        tu = TimeUnit.MILLISECONDS;
    }

    double v = (double)value / (double)tu.toMillis ( 1 );
    v = niceNum ( v, true );
    return (long) ( v * tu.toMillis ( 1 ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:29,代码来源:Helper.java

示例6: parse

@Override
public void parse(CacheBuilderSpec spec, String key, String value) {
  checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
  try {
    char lastChar = value.charAt(value.length() - 1);
    TimeUnit timeUnit;
    switch (lastChar) {
      case 'd':
        timeUnit = TimeUnit.DAYS;
        break;
      case 'h':
        timeUnit = TimeUnit.HOURS;
        break;
      case 'm':
        timeUnit = TimeUnit.MINUTES;
        break;
      case 's':
        timeUnit = TimeUnit.SECONDS;
        break;
      default:
        throw new IllegalArgumentException(
            format(
                "key %s invalid format.  was %s, must end with one of [dDhHmMsS]", key, value));
    }

    long duration = Long.parseLong(value.substring(0, value.length() - 1));
    parseDuration(spec, duration, timeUnit);
  } catch (NumberFormatException e) {
    throw new IllegalArgumentException(
        format("key %s value set to %s, must be integer", key, value));
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:32,代码来源:CacheBuilderSpec.java

示例7: computeFirstResetTime

protected static LocalDateTime computeFirstResetTime(LocalDateTime baseTime, int time, TimeUnit unit) {
    if (unit != TimeUnit.SECONDS && unit != TimeUnit.MINUTES && unit != TimeUnit.HOURS && unit != TimeUnit.DAYS) {
        throw new IllegalArgumentException();
    }
    LocalDateTime t = baseTime;
    switch (unit) {
        case DAYS:
            t = t.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
            break;
        case HOURS:
            if (24 % time == 0) {
                t = t.plusHours(time - t.getHour() % time);
            } else {
                t = t.plusHours(1);
            }
            t = t.withMinute(0).withSecond(0).withNano(0);
            break;
        case MINUTES:
            if (60 % time == 0) {
                t = t.plusMinutes(time - t.getMinute() % time);
            } else {
                t = t.plusMinutes(1);
            }
            t = t.withSecond(0).withNano(0);
            break;
        case SECONDS:
            if (60 % time == 0) {
                t = t.plusSeconds(time - t.getSecond() % time);
            } else {
                t = t.plusSeconds(1);
            }
            t = t.withNano(0);
            break;
    }
    return t;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:36,代码来源:DefaultCacheMonitorManager.java

示例8: createFromSaveString

/**
 * Creates a TimeOut object from a given, by createSaveString() generated, saveString
 * @param s the SaveString
 * @return the TimeOut object
 */
public static TimeOut createFromSaveString(String s) {
    String [] split = s.split("\n</duration>\n");
    Long duration = Long.parseLong(split[0].replace("<duration>\n", ""));
    split = split[1].split("\n</timeunit>\n");
    TimeUnit timeUnit = TimeUnit.MINUTES;
    String timeunit = split[0].replace("<timeunit>\n", "");
    switch(timeunit) {
        case "MILLISECONDS":
            timeUnit = TimeUnit.MILLISECONDS;
            break;
        case "MINUTES":
            timeUnit = TimeUnit.MINUTES;
            duration = TimeUnit.MILLISECONDS.toMinutes(duration);
            break;
        case "SECONDS":
            timeUnit = TimeUnit.SECONDS;
            duration = TimeUnit.MILLISECONDS.toSeconds(duration);
            break;
        case "HOURS":
            timeUnit = TimeUnit.HOURS;
            duration = TimeUnit.MILLISECONDS.toHours(duration);
            break;
        case "DAYS":
            timeUnit = TimeUnit.DAYS;
            duration = TimeUnit.MILLISECONDS.toDays(duration);
            break;
        default:
            break;
    }
    return new TimeOut(timeUnit, duration);
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:36,代码来源:TimeOutSaverLoader.java

示例9: ImportManager

public ImportManager(TaskListener<Void> listener, Context context) {
    this.listener = listener;
    HighMemoryGovernor governor = new HighMemoryGovernor();
    DebugManager.debugPrint("Restoring up to " + governor.concurrentTasks() + " entities at the same time.", context);
    this.poolExecutor = new ThreadPoolExecutor(governor.concurrentTasks(), governor.concurrentTasks(), 100, TimeUnit.DAYS, new ArrayBlockingQueue<Runnable>(256));
    this.context = context;
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:7,代码来源:ImportManager.java

示例10: ConcurrentExecute

/**
 * Create the ConcurrentExecute to perform a number of jobs concurrently
 * @param concurrentThreads The amount of threads to concurrently perform the job
 */
public ConcurrentExecute(int concurrentThreads) {
    this.nextId = new AtomicLong(0);
    this.jobEntries = new ArrayList<>();
    this.pool = new ThreadPoolExecutor(concurrentThreads, concurrentThreads, 1, TimeUnit.DAYS, new LinkedBlockingQueue<>());
    this.timeoutHandler = new TimeoutHandler();
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:10,代码来源:ConcurrentExecute.java

示例11: parseTimeValue

public static TimeValue parseTimeValue(String sValue, TimeValue defaultValue, String settingName) {
    settingName = Objects.requireNonNull(settingName);
    if (sValue == null) {
        return defaultValue;
    }
    final String normalized = sValue.toLowerCase(Locale.ROOT).trim();
    if (normalized.endsWith("nanos")) {
        return new TimeValue(parse(sValue, normalized, 5), TimeUnit.NANOSECONDS);
    } else if (normalized.endsWith("micros")) {
        return new TimeValue(parse(sValue, normalized, 6), TimeUnit.MICROSECONDS);
    } else if (normalized.endsWith("ms")) {
        return new TimeValue(parse(sValue, normalized, 2), TimeUnit.MILLISECONDS);
    } else if (normalized.endsWith("s")) {
        return new TimeValue(parse(sValue, normalized, 1), TimeUnit.SECONDS);
    } else if (sValue.endsWith("m")) {
        // parsing minutes should be case sensitive as `M` is generally
        // accepted to mean months not minutes. This is the only case where
        // the upper and lower case forms indicate different time units
        return new TimeValue(parse(sValue, normalized, 1), TimeUnit.MINUTES);
    } else if (normalized.endsWith("h")) {
        return new TimeValue(parse(sValue, normalized, 1), TimeUnit.HOURS);
    } else if (normalized.endsWith("d")) {
        return new TimeValue(parse(sValue, normalized, 1), TimeUnit.DAYS);
    } else if (normalized.matches("-0*1")) {
        return TimeValue.MINUS_ONE;
    } else if (normalized.matches("0+")) {
        return TimeValue.ZERO;
    } else {
        // Missing units:
        throw new ElasticsearchParseException(
            "failed to parse setting [{}] with value [{}] as a time value: unit is missing or unrecognized",
            settingName,
            sValue);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:TimeValue.java

示例12:

@LifeCache(duration = 1, timeUnit = TimeUnit.DAYS)
Single<RootSearchResponse> searchDiscogs(Single<RootSearchResponse> searchDiscogsSingle, DynamicKey searchTerm);
 
开发者ID:jbmlaird,项目名称:DiscogsBrowser,代码行数:2,代码来源:CacheProviders.java

示例13:

@LifeCache(duration = 1, timeUnit = TimeUnit.DAYS)
Observable<Reply<List<String>>> getHotWords(Observable<List<String>> strs);
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:2,代码来源:CommonCache.java

示例14: testHasDefaultProfileCreator

@Test
public void testHasDefaultProfileCreator() {
    final DirectFormClient formClient = new DirectFormClient(new LocalCachingAuthenticator<>(new SimpleTestUsernamePasswordAuthenticator(), 10, 10, TimeUnit.DAYS));
    formClient.init(null);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:5,代码来源:DirectFormClientTests.java

示例15: testTimeout

/**
 * Test of class TimeoutValueHandler testing both input and output at different configurations.
 */
@Test
public void testTimeout() {
    System.out.println("set/getTimeout");
    JComboBox<String> comboBox = new JComboBox<String>();
    JSpinner spinner = new JSpinner();
    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
    model.addElement("s");
    model.addElement("m");
    model.addElement("h");
    model.addElement("d");
    model.addElement("faultyEntry");
    comboBox.setModel(model);
    TimeoutValueHandler handler = new TimeoutValueHandler(spinner, comboBox);
    handler.setReacts(true);
    spinner.setValue(1);
    comboBox.setSelectedIndex(2);
    TimeOut expResult = new TimeOut(TimeUnit.SECONDS, 0);
    spinner.setValue(0);
    comboBox.setSelectedIndex(0);
    handler.setValue(handler.getTimeout());
    TimeOut result = handler.getTimeout();
    boolean minTest = (expResult.getDuration() == result.getDuration()
            && expResult.getOrigUnit().equals(result.getOrigUnit())
            && !result.isActive());
    expResult = new TimeOut(TimeUnit.DAYS, 3653);
    spinner.setValue(3653);
    comboBox.setSelectedIndex(3);
    handler.setValue(handler.getTimeout());
    result = handler.getTimeout();
    boolean maxTest = (expResult.getDuration() == result.getDuration()
            && expResult.getOrigUnit().equals(result.getOrigUnit())
            && result.isActive());
    expResult = new TimeOut(TimeUnit.DAYS, 0);
    spinner.setValue(-1);
    handler.setValue(handler.getTimeout());
    result = handler.getTimeout();
    boolean falseValueTest = (expResult.getDuration() == result.getDuration()
            && expResult.getOrigUnit().equals(result.getOrigUnit())
            && !result.isActive());
    expResult = new TimeOut(TimeUnit.SECONDS, 0);
    spinner.setValue(42);
    comboBox.setSelectedIndex(4);
    handler.setValue(handler.getTimeout());
    result = handler.getTimeout();
    //System.out.println(handler.hasChanged() + " max " + handler.getTimeout().getDuration() + " " + handler.getTimeout().getOrigUnit());
    //System.out.println(handler.hasChanged() + " max " + expResult.getDuration() + " " + expResult.getOrigUnit());
    boolean falseUnitTest = (expResult.getDuration() == result.getDuration()
            && expResult.getOrigUnit().equals(result.getOrigUnit())
            && !result.isActive());
    assertTrue(minTest && maxTest && falseValueTest && falseUnitTest);
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:54,代码来源:TimeoutValueHandlerTest.java


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