本文整理了Java中org.threeten.bp.Instant.ofEpochMilli()
方法的一些代码示例,展示了Instant.ofEpochMilli()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instant.ofEpochMilli()
方法的具体详情如下:
包路径:org.threeten.bp.Instant
类名称:Instant
方法名:ofEpochMilli
[英]Obtains an instance of Instant using milliseconds from the epoch of 1970-01-01T00:00:00Z.
The seconds and nanoseconds are extracted from the specified milliseconds.
[中]从1970-01-01T00:00:00Z的历元中以毫秒为单位获取Instant的实例。
秒和纳秒从指定的毫秒中提取。
代码示例来源:origin: googleapis/google-cloud-java
@Override
public Instant instant() {
return Instant.ofEpochMilli(currentTimeMillis);
}
}
代码示例来源:origin: googleapis/google-cloud-java
private Instant now() {
return Instant.ofEpochMilli(clock.millisTime());
}
}
代码示例来源:origin: googleapis/google-cloud-java
case TIMESTAMP:
if (value instanceof Long) {
return timestampFormatter.format(Instant.ofEpochMilli(((Long) value) / 1000));
} else if (value instanceof String) {
代码示例来源:origin: googleapis/google-cloud-java
private void work() {
Instant cmpTime = Instant.ofEpochMilli(clock.millisTime());
for (; ; ) {
PendingCallable<?> callable = null;
synchronized (pendingCallables) {
if (pendingCallables.isEmpty()
|| pendingCallables.peek().getScheduledTime().isAfter(cmpTime)) {
break;
}
callable = pendingCallables.poll();
}
if (callable != null) {
try {
callable.call();
} catch (Exception e) {
// We ignore any callable exception, which should be set to the future but not relevant to
// advanceTime.
}
}
}
synchronized (pendingCallables) {
if (shutdown.get() && pendingCallables.isEmpty()) {
pendingCallables.notifyAll();
}
}
}
代码示例来源:origin: googleapis/google-cloud-java
break;
case FIXED_DELAY:
this.creationTime = Instant.ofEpochMilli(clock.millisTime());
schedulePendingCallable(this);
break;
代码示例来源:origin: googleapis/google-cloud-java
DateTimeFormatter.ISO_DATE_TIME
.withZone(ZoneOffset.UTC)
.format(Instant.ofEpochMilli(System.currentTimeMillis())));
if (projects.putIfAbsent(project.getProjectId(), project) != null) {
return Error.ALREADY_EXISTS.response(
代码示例来源:origin: googleapis/google-cloud-java
Change toPb() {
Change pb = new Change();
// set id
if (getGeneratedId() != null) {
pb.setId(getGeneratedId());
}
// set timestamp
if (getStartTimeMillis() != null) {
pb.setStartTime(
DateTimeFormatter.ISO_DATE_TIME
.withZone(ZoneOffset.UTC)
.format(Instant.ofEpochMilli(getStartTimeMillis())));
}
// set status
if (status() != null) {
pb.setStatus(status().name().toLowerCase());
}
// set a list of additions
pb.setAdditions(Lists.transform(getAdditions(), RecordSet.TO_PB_FUNCTION));
// set a list of deletions
pb.setDeletions(Lists.transform(getDeletions(), RecordSet.TO_PB_FUNCTION));
return pb;
}
代码示例来源:origin: googleapis/google-cloud-java
ManagedZone toPb() {
ManagedZone pb = new ManagedZone();
pb.setDescription(this.getDescription());
pb.setDnsName(this.getDnsName());
if (this.getGeneratedId() != null) {
pb.setId(new BigInteger(this.getGeneratedId()));
}
pb.setName(this.getName());
pb.setNameServers(this.nameServers); // do use real attribute value which may be null
pb.setNameServerSet(this.getNameServerSet());
if (this.getCreationTimeMillis() != null) {
pb.setCreationTime(
DATE_TIME_FORMATTER.format(Instant.ofEpochMilli(this.getCreationTimeMillis())));
}
return pb;
}
代码示例来源:origin: googleapis/google-cloud-java
com.google.api.services.cloudresourcemanager.model.Project toPb() {
com.google.api.services.cloudresourcemanager.model.Project projectPb =
new com.google.api.services.cloudresourcemanager.model.Project();
projectPb.setName(name);
projectPb.setProjectId(projectId);
projectPb.setLabels(labels);
projectPb.setProjectNumber(projectNumber);
if (state != null) {
projectPb.setLifecycleState(state.toString());
}
if (createTimeMillis != null) {
projectPb.setCreateTime(
DateTimeFormatter.ISO_DATE_TIME
.withZone(ZoneOffset.UTC)
.format(Instant.ofEpochMilli(createTimeMillis)));
}
if (parent != null) {
projectPb.setParent(parent.toPb());
}
return projectPb;
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Converts a {@code java.util.Date} to an {@code Instant}.
*
* @param utilDate the util date, not null
* @return the instant, not null
*/
public static Instant toInstant(Date utilDate) {
return Instant.ofEpochMilli(utilDate.getTime());
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Converts a {@code Calendar} to an {@code Instant}.
*
* @param calendar the calendar, not null
* @return the instant, not null
*/
public static Instant toInstant(Calendar calendar) {
return Instant.ofEpochMilli(calendar.getTimeInMillis());
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Converts a {@code java.util.Date} to an {@code Instant}.
*
* @param utilDate the util date, not null
* @return the instant, not null
*/
public static Instant toInstant(Date utilDate) {
return Instant.ofEpochMilli(utilDate.getTime());
}
代码示例来源:origin: ThreeTen/threetenbp
@Override
public Instant instant() {
return Instant.ofEpochMilli(millis());
}
@Override
代码示例来源:origin: org.threeten/threetenbp
@Override
public Instant instant() {
return Instant.ofEpochMilli(millis());
}
@Override
代码示例来源:origin: mercadolibre/java-sdk
@Override
public OffsetDateTime apply(FromIntegerArguments a) {
return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
},
代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp
@Override
public ZonedDateTime apply(FromIntegerArguments a) {
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
},
代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp
@Override
public OffsetDateTime apply(FromIntegerArguments a) {
return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
},
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public LocalTime convert(Date source) {
return ofInstant(ofEpochMilli(source.getTime()), systemDefault()).toLocalTime();
}
}
代码示例来源:origin: ThreeTen/threetenbp
@Override
public Instant instant() {
if ((tickNanos % 1000000) == 0) {
long millis = baseClock.millis();
return Instant.ofEpochMilli(millis - Jdk8Methods.floorMod(millis, tickNanos / 1000000L));
}
Instant instant = baseClock.instant();
long nanos = instant.getNano();
long adjust = Jdk8Methods.floorMod(nanos, tickNanos);
return instant.minusNanos(adjust);
}
@Override
代码示例来源:origin: org.threeten/threetenbp
@Override
public Instant instant() {
if ((tickNanos % 1000000) == 0) {
long millis = baseClock.millis();
return Instant.ofEpochMilli(millis - Jdk8Methods.floorMod(millis, tickNanos / 1000000L));
}
Instant instant = baseClock.instant();
long nanos = instant.getNano();
long adjust = Jdk8Methods.floorMod(nanos, tickNanos);
return instant.minusNanos(adjust);
}
@Override
内容来源于网络,如有侵权,请联系作者删除!