当前位置: 首页>>代码示例>>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;未经允许,请勿转载。