@Override public Instant instant() { return Instant.ofEpochMilli(currentTimeMillis); } }
private Instant now() { return Instant.ofEpochMilli(clock.millisTime()); } }
case TIMESTAMP: if (value instanceof Long) { return timestampFormatter.format(Instant.ofEpochMilli(((Long) value) / 1000)); } else if (value instanceof String) {
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(); } } }
break; case FIXED_DELAY: this.creationTime = Instant.ofEpochMilli(clock.millisTime()); schedulePendingCallable(this); break;
DateTimeFormatter.ISO_DATE_TIME .withZone(ZoneOffset.UTC) .format(Instant.ofEpochMilli(System.currentTimeMillis()))); if (projects.putIfAbsent(project.getProjectId(), project) != null) { return Error.ALREADY_EXISTS.response(
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; }
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; }
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; }
/** * 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()); }
/** * 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()); }
/** * 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()); }
@Override public Instant instant() { return Instant.ofEpochMilli(millis()); } @Override
@Override public Instant instant() { return Instant.ofEpochMilli(millis()); } @Override
@Override public OffsetDateTime apply(FromIntegerArguments a) { return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); } },
@Override public ZonedDateTime apply(FromIntegerArguments a) { return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); } },
@Override public OffsetDateTime apply(FromIntegerArguments a) { return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); } },
@Nonnull @Override public LocalTime convert(Date source) { return ofInstant(ofEpochMilli(source.getTime()), systemDefault()).toLocalTime(); } }
@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
@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