當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTime.plus方法代碼示例

本文整理匯總了Java中org.joda.time.DateTime.plus方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTime.plus方法的具體用法?Java DateTime.plus怎麽用?Java DateTime.plus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.DateTime的用法示例。


在下文中一共展示了DateTime.plus方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: formatDuration

import org.joda.time.DateTime; //導入方法依賴的package包/類
public static String formatDuration(long duration)
{
	// Using Joda Time
	DateTime now = new DateTime(); // Now
	DateTime plus = now.plus(new Duration(duration * 1000));

	// Define and calculate the interval of time
	Interval interval = new Interval(now.getMillis(), plus.getMillis());
	Period period = interval.toPeriod(PeriodType.time());

	// Define the period formatter for pretty printing
	String ampersand = " & ";
	PeriodFormatter pf = new PeriodFormatterBuilder().appendHours().appendSuffix(ds("hour"), ds("hours"))
		.appendSeparator(" ", ampersand).appendMinutes().appendSuffix(ds("minute"), ds("minutes"))
		.appendSeparator(ampersand).appendSeconds().appendSuffix(ds("second"), ds("seconds")).toFormatter();

	return pf.print(period).trim();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:EchoUtils.java

示例2: countTimes

import org.joda.time.DateTime; //導入方法依賴的package包/類
public double[] countTimes(Map<String, double[]> table, DateTime date) {
	DateTime d = date;
	double[] ret = new double[3 * Type.values().length];
	for (int i = 0; i < ret.length; i++) ret[i] = 0;
	for (int i = 0; i < iWindow; i++) {
		double[] count = table.get(format(d));
		if (count != null)
			for (int j = 0; j < count.length; j++) {
				if ((j % 3) == 2)
					ret[j] = Math.max(ret[j], count[j]);
				else
					ret[j] += count[j];
			}
		d = d.plus(iIncrement);
	}
	return ret;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:18,代碼來源:QueryLog.java

示例3: getTimeTo

import org.joda.time.DateTime; //導入方法依賴的package包/類
private DateTime getTimeTo(IntentRequest request, DateTime from) {
  final String sDuration = sv(request, SLOT_DURATION);
  final String sDateFrom = sv(request, SLOT_DATE_FROM);
  final String sDateTo = sv(request, SLOT_DATE_TO);
  final String sTimeTo = sv(request, SLOT_TIME_TO);

  if(sTimeTo != null) {
    if(sDateTo != null) {
      return DateTime.parse(sDateTo + "T" + sTimeTo);
    }

    return DateTime.parse(sDateFrom + "T" + sTimeTo);
  } else if(sDateTo != null) {
    return DateTime.parse(sDateTo).withTimeAtStartOfDay();
  }

  final Duration duration = Duration.parse(sDuration);
  return from.plus(duration.toMillis());
}
 
開發者ID:rainu,項目名稱:alexa-skill,代碼行數:20,代碼來源:NewEventSpeechlet.java

示例4: countUsers

import org.joda.time.DateTime; //導入方法依賴的package包/類
public double[] countUsers(Map<String, int[]> table, DateTime date) {
	DateTime d = date;
	int[] ret = new int[2];
	for (int i = 0; i < ret.length; i++) ret[i] = 0;
	for (int i = 0; i < iWindow; i++) {
		int[] count = table.get(format(d));
		if (count != null)
			for (int j = 0; j < count.length; j++) ret[j] += count[j];
		d = d.plus(iIncrement);
	}
	return new double[] { ((double)ret[0]) / iWindow, ((double)ret[1]) / iWindow };
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:13,代碼來源:QueryLog.java

示例5: countQueries

import org.joda.time.DateTime; //導入方法依賴的package包/類
public int[] countQueries(Map<String, int[]> table, DateTime date) {
	DateTime d = date;
	int[] ret = new int[Type.values().length];
	for (int i = 0; i < ret.length; i++) ret[i] = 0;
	for (int i = 0; i < iWindow; i++) {
		int[] count = table.get(format(d));
		if (count != null)
			for (int j = 0; j < count.length; j++) ret[j] += count[j];
		d = d.plus(iIncrement);
	}
	return ret;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:13,代碼來源:QueryLog.java

示例6: getNextTriggerTime

import org.joda.time.DateTime; //導入方法依賴的package包/類
public DateTime getNextTriggerTime() {
    DateTime now = DateTime.now();
    DateTime target = now
            .withHourOfDay(getHourOfDay())
            .withMinuteOfHour(getMinute())
            .withSecondOfMinute(0)
            .withMillisOfSecond(0);

    return target.isBefore(now) ? target.plus(REPEAT_DURATION) : target;
}
 
開發者ID:KevinLiddle,項目名稱:crockpod,代碼行數:11,代碼來源:Alarm.java

示例7: getEarliestExpiration

import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
 * Gets the earliest expiration instant within a metadata tree.
 * 
 * @param xmlObject the metadata
 * @param earliestExpiration the earliest expiration instant
 * @param now when this method was called
 * 
 * @return the earliest expiration instant within a metadata tree
 */
public static DateTime getEarliestExpiration(XMLObject xmlObject, DateTime earliestExpiration, DateTime now) {

    // expiration time for a specific element
    DateTime elementExpirationTime;

    // Test duration based times
    if (xmlObject instanceof CacheableSAMLObject) {
        CacheableSAMLObject cacheInfo = (CacheableSAMLObject) xmlObject;

        if (cacheInfo.getCacheDuration() != null && cacheInfo.getCacheDuration().longValue() > 0) {
            elementExpirationTime = now.plus(cacheInfo.getCacheDuration().longValue());
            if (earliestExpiration == null) {
                earliestExpiration = elementExpirationTime;
            } else {
                if (elementExpirationTime != null && elementExpirationTime.isBefore(earliestExpiration)) {
                    earliestExpiration = elementExpirationTime;
                }
            }
        }
    }

    // Test instant based times
    if (xmlObject instanceof TimeBoundSAMLObject) {
        TimeBoundSAMLObject timeBoundObject = (TimeBoundSAMLObject) xmlObject;
        elementExpirationTime = timeBoundObject.getValidUntil();
        if (earliestExpiration == null) {
            earliestExpiration = elementExpirationTime;
        } else {
            if (elementExpirationTime != null && elementExpirationTime.isBefore(earliestExpiration)) {
                earliestExpiration = elementExpirationTime;
            }
        }
    }

    // Inspect children
    List<XMLObject> children = xmlObject.getOrderedChildren();
    if (children != null) {
        for (XMLObject child : xmlObject.getOrderedChildren()) {
            if (child != null) {
                earliestExpiration = getEarliestExpiration(child, earliestExpiration, now);
            }
        }
    }

    return earliestExpiration;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:56,代碼來源:SAML2Helper.java

示例8: next

import org.joda.time.DateTime; //導入方法依賴的package包/類
public DateTime next(DateTime date, DateTime now) {
	DateTime ret = date.plus(iIncrement);
	return (ret.isAfter(now) ? null : ret);
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:5,代碼來源:QueryLog.java

示例9: getExamExpirationDate

import org.joda.time.DateTime; //導入方法依賴的package包/類
public static DateTime getExamExpirationDate(DateTime timeOfSubmission) {
    String expiresAfter = ConfigFactory.load().getString("sitnet.exam.expiration.period");
    Period period = Period.parse(expiresAfter);
    return timeOfSubmission.plus(period);
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:6,代碼來源:AppUtil.java


注:本文中的org.joda.time.DateTime.plus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。