本文整理匯總了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);
}