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


Java Seconds.getSeconds方法代码示例

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


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

示例1: convertTime

import org.joda.time.Seconds; //导入方法依赖的package包/类
private int convertTime(String time) {
    PeriodFormatter formatter = ISOPeriodFormat.standard();
    Period p = formatter.parsePeriod(time);
    Seconds s = p.toStandardSeconds();

    return s.getSeconds();
}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:8,代码来源:OnlineTotalSearchTask.java

示例2: sessionTooOld

import org.joda.time.Seconds; //导入方法依赖的package包/类
private boolean sessionTooOld() {
    Seconds secondsSinceLastSessionUpdate = Seconds.secondsBetween(sessionLastUpdated,
            new DateTime(DateTimeZone.forID("EST5EDT")));
    log.info("seconds since last session update: " + secondsSinceLastSessionUpdate.getSeconds());
    if (secondsSinceLastSessionUpdate.getSeconds() > 240) {
        return true;
    }
    return false;

}
 
开发者ID:bullhorn,项目名称:starter-kit-spring-maven,代码行数:11,代码来源:BullhornAPISoap.java

示例3: diffInSeconds

import org.joda.time.Seconds; //导入方法依赖的package包/类
private int diffInSeconds(DateTime a, DateTime b) {
    Seconds diff;
    if (a.isBefore(b)) {
        diff = Seconds.secondsBetween(a, b);
    } else {
        diff = Seconds.secondsBetween(b, a);
    }
    return diff.getSeconds();
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:10,代码来源:VetumaController.java

示例4: getConvertedTime

import org.joda.time.Seconds; //导入方法依赖的package包/类
public ConvertedTime getConvertedTime(long duration) {
    Set<Seconds> keys = RULES.keySet();
    for (Seconds seconds : keys) {
        if (duration <= seconds.getSeconds()) {
            return RULES.get(seconds).getConvertedTime(duration);
        }
    }
    return new TimeConverter.OverTwoYears().getConvertedTime(duration);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:10,代码来源:TimeConverter.java

示例5: getRemainingTime

import org.joda.time.Seconds; //导入方法依赖的package包/类
protected static int getRemainingTime() {
    DateTime now = DateTime.now();
    Seconds pastTime = Seconds.secondsBetween(Context.getStartCurrentScenario(), now);
    int totalTimecalculated = pastTime.getSeconds() * Context.getDataInputProvider().getNbGherkinExample() / Context.getCurrentScenarioData();
    return totalTimecalculated - pastTime.getSeconds();
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:7,代码来源:CucumberHooks.java

示例6: relative

import org.joda.time.Seconds; //导入方法依赖的package包/类
/**
 * Returns a string indicating the distance between {@link DateTime}s. Defaults to comparing the input {@link DateTime} to
 * the current time.
 */
public static @NonNull String relative(final @NonNull Context context, final @NonNull KSString ksString,
  final @NonNull DateTime dateTime, final @NonNull RelativeDateTimeOptions options) {

  final DateTime relativeToDateTime = ObjectUtils.coalesce(options.relativeToDateTime(), DateTime.now());
  final Seconds seconds = Seconds.secondsBetween(dateTime, relativeToDateTime);
  final int secondsDifference = seconds.getSeconds();

  if (secondsDifference >= 0.0 && secondsDifference <= 60.0) {
    return context.getString(R.string.dates_just_now);
  } else if (secondsDifference >= -60.0 && secondsDifference <= 0.0) {
    return context.getString(R.string.dates_right_now);
  }

  final Pair<String, Integer> unitAndDifference = unitAndDifference(secondsDifference, options.threshold());
  if (unitAndDifference == null) {
    // Couldn't find a good match, just render the date.
    return mediumDate(dateTime);
  }

  final String unit = unitAndDifference.first;
  final int difference = unitAndDifference.second;
  boolean willHappenIn = false;
  boolean happenedAgo = false;

  if (!options.absolute()) {
    if (secondsDifference < 0) {
      willHappenIn = true;
    } else if (secondsDifference > 0) {
      happenedAgo = true;
    }
  }

  if (happenedAgo && "days".equals(unit) && difference == 1) {
    return context.getString(R.string.dates_yesterday);
  }

  final StringBuilder baseKeyPath = new StringBuilder();
  if (willHappenIn) {
    baseKeyPath.append(String.format("dates_time_in_%s", unit));
  } else if (happenedAgo) {
    baseKeyPath.append(String.format("dates_time_%s_ago", unit));
  } else {
    baseKeyPath.append(String.format("dates_time_%s", unit));
  }

  if (options.abbreviated()) {
    baseKeyPath.append("_abbreviated");
  }

  return ksString.format(baseKeyPath.toString(), difference,
    "time_count", NumberUtils.format(difference, NumberOptions.builder().build()));
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:57,代码来源:DateTimeUtils.java

示例7: seconds_between_two_dates_in_java_with_joda

import org.joda.time.Seconds; //导入方法依赖的package包/类
@Test
public void seconds_between_two_dates_in_java_with_joda () {

	// start day is 1 day in the past
	DateTime startDate = new DateTime().minusDays(1);
	DateTime endDate = new DateTime();
	
	Seconds seconds = Seconds.secondsBetween(startDate, endDate);
	
	int secondsInDay = seconds.getSeconds();
	
	assertEquals(86400, secondsInDay);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:14,代码来源:SecondsBetweenDates.java


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