本文整理汇总了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();
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
示例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()));
}
示例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);
}