本文整理了Java中org.joda.time.LocalTime.plusMillis()
方法的一些代码示例,展示了LocalTime.plusMillis()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalTime.plusMillis()
方法的具体详情如下:
包路径:org.joda.time.LocalTime
类名称:LocalTime
方法名:plusMillis
[英]Returns a copy of this time plus the specified number of millis.
This LocalTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalTime added = dt.plusMillis(6);
LocalTime added = dt.plus(Period.millis(6));
LocalTime added = dt.withFieldAdded(DurationFieldType.millis(), 6);
[中]返回此时间加上指定毫秒数的副本。
此LocalTime实例是不可变的,不受此方法调用的影响。
以下三行实际上是相同的:
LocalTime added = dt.plusMillis(6);
LocalTime added = dt.plus(Period.millis(6));
LocalTime added = dt.withFieldAdded(DurationFieldType.millis(), 6);
代码示例来源:origin: stackoverflow.com
long movingAverage = 0;
// 1. define offset
LocalTime offset = new LocalTime("12:00:00");
long offsetMillis = offset.getMillisOfDay();
for (String date : times) {
long sampleMillis = new LocalTime(date).getMillisOfDay();
// align to offset
if (sampleMillis < offsetMillis)
sampleMillis += DateTimeConstants.MILLIS_PER_DAY;
long diff = sampleMillis - offsetMillis;
// 2. use moving average
movingAverage = movingAverage + diff / times.size();
}
// 3. avoid LocalTime(long) constructor
LocalTime result = offset.plusMillis((int) movingAverage);
System.out.println(result); // 23:48:54.329
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
protected void buildNodeNames() {
this.nodeNames.clear();
if (nodes != null && !nodes.isEmpty()) {
for (int i = 0; i < nodes.size(); i++) {
TimeNode node = nodes.get(i);
StringBuilder sb = new StringBuilder(node.getName());
sb.append("\n");
boolean arrive = i > 0;
boolean depart = i < nodes.size() - 1;
boolean passage = node.getPause() == null || node.getPause().getMillis() == 0;
if (arrive || passage) {
sb.append(node.getTime().toString(StaticWidgetHelper.getSynaptixDateConstantsBundle().displayTimeFormat()));
}
if (arrive && depart && !passage) {
sb.append(" - ");
}
if (depart && !passage) {
sb.append(node.getTime().plusMillis((int) node.getPause().getMillis()).toString(StaticWidgetHelper.getSynaptixDateConstantsBundle().displayTimeFormat()));
}
nodeNames.add(sb.toString());
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!