本文整理了Java中java.time.LocalTime.plusSeconds()
方法的一些代码示例,展示了LocalTime.plusSeconds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalTime.plusSeconds()
方法的具体详情如下:
包路径:java.time.LocalTime
类名称:LocalTime
方法名:plusSeconds
[英]Returns a copy of this LocalTime with the specified period in seconds added.
This adds the specified number of seconds to this time, returning a new time. The calculation wraps around midnight.
This instance is immutable and unaffected by this method call.
[中]返回此LocalTime的副本,并添加指定的时间段(以秒为单位)。
这会将指定的秒数添加到此时间,并返回一个新时间。计算时间大约在午夜。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: Alluxio/alluxio
/**
* Primitive that is invoked periodically for cleaning the registry from clients that has become
* stale.
*/
private void cleanupStaleClients() {
LocalTime cleanupTime = LocalTime.now();
LOG.debug("Starting cleanup authentication registry at {}", cleanupTime);
// Get a list of stale clients under read lock.
List<UUID> staleChannels = new ArrayList<>();
for (Map.Entry<UUID, AuthenticatedChannelInfo> clientEntry : mChannels.entrySet()) {
LocalTime lat = clientEntry.getValue().getLastAccessTime();
if (lat.plusSeconds(mCleanupIntervalMs / 1000).isBefore(cleanupTime)) {
staleChannels.add(clientEntry.getKey());
}
}
// Unregister stale clients.
LOG.debug("Found {} stale channels for cleanup.", staleChannels.size());
for (UUID clientId : staleChannels) {
unregisterChannel(clientId);
}
LOG.debug("Finished state channel cleanup at {}", LocalTime.now());
}
代码示例来源:origin: org.codehaus.groovy/groovy-datetime
/**
* Returns a {@link java.time.LocalTime} that is {@code seconds} seconds after this time.
*
* @param self a LocalTime
* @param seconds the number of seconds to add
* @return a LocalTime
* @since 2.5.0
*/
public static LocalTime plus(final LocalTime self, long seconds) {
return self.plusSeconds(seconds);
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Returns a copy of this {@code LocalTime} with the specified period in seconds subtracted.
* <p>
* This subtracts the specified number of seconds from this time, returning a new time.
* The calculation wraps around midnight.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param secondsToSubtract the seconds to subtract, may be negative
* @return a {@code LocalTime} based on this time with the seconds subtracted, not null
*/
public LocalTime minusSeconds(long secondsToSubtract) {
return plusSeconds(-(secondsToSubtract % SECONDS_PER_DAY));
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Returns a copy of this {@code OffsetTime} with the specified period in seconds added.
* <p>
* This adds the specified number of seconds to this time, returning a new time.
* The calculation wraps around midnight.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param seconds the seconds to add, may be negative
* @return an {@code OffsetTime} based on this time with the seconds added, not null
*/
public OffsetTime plusSeconds(long seconds) {
return with(time.plusSeconds(seconds), offset);
}
代码示例来源:origin: stackoverflow.com
import java.time.LocalTime;
private String ConvertSecondToHHMMSSString(int nSecondTime) {
return LocalTime.MIN.plusSeconds(nSecondTime).toString();
}
代码示例来源:origin: org.exparity/exparity-stub
/**
* Build a random {@link LocalTime} within 12 hours either side of now. For example
* <p/>
* <code>
* LocalTime aRandomTime = RandomBuilder.aRandomLocalTime();
* </code>
*
* @return a random {@link aRandomLocalTime} within 12 hours either side of now.
*/
public static LocalTime aRandomLocalTime() {
return LocalTime.now().plusSeconds(nextInt(SECONDS_IN_12_HOURS));
}
代码示例来源:origin: com.namics.oss/java-random
@Override
public LocalTime random() {
LocalTime now = LocalTime.now();
int day = 60 * 60 * 24;
return now.plusSeconds((long) RandomData.randomInteger(-1 * day, day));// +- 1 day;
}
代码示例来源:origin: org.geoserver.community/gs-status-monitoring
public String getValueUnit() {
if (!available || value == null) {
return BaseSystemInfoCollector.DEFAULT_VALUE;
}
if (value instanceof Double || value instanceof Float) {
return String.format("%.2f %s", value, unit);
}
if (unit != null && unit.equalsIgnoreCase("bytes")) {
long bytes = Converters.convert(value, Long.class);
return humanReadableByteCount(bytes);
} else if (unit != null && unit.equalsIgnoreCase("sec")) {
long seconds = Converters.convert(value, Long.class);
return LocalTime.MIN.plusSeconds(seconds).toString();
}
return String.format("%s %s", value, unit);
}
代码示例来源:origin: com.healthmarketscience.jackcess/jackcess
@Override
protected Value eval3(EvalContext ctx, Value param1, Value param2, Value param3) {
int hours = param1.getAsLongInt(ctx);
int minutes = param2.getAsLongInt(ctx);
int seconds = param3.getAsLongInt(ctx);
// we have to construct incrementatlly to handle out of range values
LocalTime lt = ColumnImpl.BASE_LT.plusHours(hours).plusMinutes(minutes)
.plusSeconds(seconds);
return ValueSupport.toValue(lt);
}
});
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Returns a copy of this {@code OffsetTime} with the specified offset ensuring
* that the result is at the same instant on an implied day.
* <p>
* This method returns an object with the specified {@code ZoneOffset} and a {@code LocalTime}
* adjusted by the difference between the two offsets.
* This will result in the old and new objects representing the same instant an an implied day.
* This is useful for finding the local time in a different offset.
* For example, if this time represents {@code 10:30+02:00} and the offset specified is
* {@code +03:00}, then this method will return {@code 11:30+03:00}.
* <p>
* To change the offset without adjusting the local time use {@link #withOffsetSameLocal}.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param offset the zone offset to change to, not null
* @return an {@code OffsetTime} based on this time with the requested offset, not null
*/
public OffsetTime withOffsetSameInstant(ZoneOffset offset) {
if (offset.equals(this.offset)) {
return this;
}
int difference = offset.getTotalSeconds() - this.offset.getTotalSeconds();
LocalTime adjusted = time.plusSeconds(difference);
return new OffsetTime(adjusted, offset);
}
代码示例来源:origin: stackoverflow.com
@Override
LocalTime increment(LocalTime time, int steps) {
return time.plusSeconds(steps);
代码示例来源:origin: com.github.seratch/java-time-backport
case MICROS: return plusNanos((amountToAdd % MICROS_PER_DAY) * 1000);
case MILLIS: return plusNanos((amountToAdd % MILLIS_PER_DAY) * 1000000);
case SECONDS: return plusSeconds(amountToAdd);
case MINUTES: return plusMinutes(amountToAdd);
case HOURS: return plusHours(amountToAdd);
代码示例来源:origin: stackoverflow.com
LocalTime now = LocalTime.now();
for (int i = 1 ; i <= 50 ; i++) {
Item item = new Item("Item "+i, now.plusSeconds(rng.nextInt(120) - 60));
table.getItems().add(item);
代码示例来源:origin: com.github.seratch/java-time-backport
case MILLI_OF_DAY: return LocalTime.ofNanoOfDay(newValue * 1000000);
case SECOND_OF_MINUTE: return withSecond((int) newValue);
case SECOND_OF_DAY: return plusSeconds(newValue - toSecondOfDay());
case MINUTE_OF_HOUR: return withMinute((int) newValue);
case MINUTE_OF_DAY: return plusMinutes(newValue - (hour * 60 + minute));
代码示例来源:origin: dbs-leipzig/gradoop
create(TIME_VAL_c),
create(TIME_VAL_c),
create(TIME_VAL_c.plusSeconds(1L))
);
内容来源于网络,如有侵权,请联系作者删除!