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