本文整理匯總了Java中org.apache.commons.lang3.time.DateUtils.addMilliseconds方法的典型用法代碼示例。如果您正苦於以下問題:Java DateUtils.addMilliseconds方法的具體用法?Java DateUtils.addMilliseconds怎麽用?Java DateUtils.addMilliseconds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.time.DateUtils
的用法示例。
在下文中一共展示了DateUtils.addMilliseconds方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createEdges
import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
private List<Edge> createEdges(final String line) {
final String[] t = line.split(",");
final String road = t[0];
final String junctionA = t[1];
final String junctionB = t[2];
final Date timestamp;
try {
timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(t[3]);
} catch (final ParseException e) {
throw new IllegalArgumentException("Invalid date: " + t[3]);
}
final Date startDate = DateUtils.truncate(timestamp, Calendar.DAY_OF_MONTH);
final Date endDate = DateUtils.addMilliseconds(DateUtils.addDays(startDate, 1), -1);
return Arrays.asList(
new Edge.Builder()
.group("RoadHasJunction")
.source(road)
.dest(junctionA)
.directed(true)
.build(),
new Edge.Builder()
.group("RoadHasJunction")
.source(road)
.dest(junctionB)
.directed(true)
.build(),
new Edge.Builder()
.group("RoadUse")
.source(junctionA)
.dest(junctionB)
.directed(true)
.property("count", 1L)
.property("startDate", startDate)
.property("endDate", endDate)
.build()
);
}
開發者ID:gchq,項目名稱:gaffer-doc,代碼行數:43,代碼來源:RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator.java
示例2: _apply
import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
@Override
public Iterable<Element> _apply(final String line) {
final String[] t = line.split(",");
final String road = t[0];
final String junctionA = t[1];
final String junctionB = t[2];
final Date timestamp;
try {
timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(t[3]);
} catch (final ParseException e) {
throw new IllegalArgumentException("Invalid date: " + t[3]);
}
final Date startDate = DateUtils.truncate(timestamp, Calendar.DAY_OF_MONTH);
final Date endDate = DateUtils.addMilliseconds(DateUtils.addDays(startDate, 1), -1);
return Arrays.asList(
new Edge.Builder()
.group("RoadHasJunction")
.source(road)
.dest(junctionA)
.directed(true)
.build(),
new Edge.Builder()
.group("RoadHasJunction")
.source(road)
.dest(junctionB)
.directed(true)
.build(),
new Edge.Builder()
.group("RoadUse")
.source(junctionA)
.dest(junctionB)
.directed(true)
.property("count", 1L)
.property("startDate", startDate)
.property("endDate", endDate)
.build()
);
}
示例3: addMilliseconds
import org.apache.commons.lang3.time.DateUtils; //導入方法依賴的package包/類
/**
* @param date 當前時間
* @param amount 增加毫秒
* @return 增加後時間
* @description 添加毫秒
*/
public static Date addMilliseconds(Date date, int amount) {
return DateUtils.addMilliseconds(date, amount);
}