當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。