com.google.cloud.datastore.Entity.getTimestamp()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中com.google.cloud.datastore.Entity.getTimestamp()方法的一些代码示例,展示了Entity.getTimestamp()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getTimestamp()方法的具体详情如下:
包路径:com.google.cloud.datastore.Entity
类名称:Entity
方法名:getTimestamp

Entity.getTimestamp介绍

暂无

代码示例

代码示例来源:origin: google/data-transfer-project

private static Map<String, Object> getProperties(Entity entity)
  throws IOException, ClassNotFoundException {
 if (entity == null) {
  return null;
 }
 ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
 for (String property : entity.getNames()) {
  // builder.put(property, entity.getValue(property));
  if (entity.getValue(property) instanceof StringValue) {
   builder.put(property, (String) entity.getString(property));
  } else if (entity.getValue(property) instanceof LongValue) {
   // This conversion is safe because of integer to long conversion above
   builder.put(property, new Long(entity.getLong(property)).intValue());
  } else if (entity.getValue(property) instanceof DoubleValue) {
   builder.put(property, (Double) entity.getDouble(property));
  } else if (entity.getValue(property) instanceof BooleanValue) {
   builder.put(property, (Boolean) entity.getBoolean(property));
  } else if (entity.getValue(property) instanceof TimestampValue) {
   builder.put(property, (Timestamp) entity.getTimestamp(property));
  } else {
   Blob blob = entity.getBlob(property);
   Object obj = null;
   try (ObjectInputStream in = new ObjectInputStream(blob.asInputStream())) {
    obj = in.readObject();
   }
   builder.put(property, obj); // BlobValue
  }
 }
 return builder.build();
}

代码示例来源:origin: googleapis/google-cloud-java

while (results.hasNext()) {
 Entity result = results.next();
 sortedComments.put(result.getTimestamp("timestamp"), result.getString("content"));
 resultCount++;

代码示例来源:origin: GoogleCloudPlatform/java-docs-samples

/**
 * Converts a list of task entities to a list of formatted task strings.
 *
 * @param tasks An iterator over task entities
 * @return A list of tasks strings, one per entity
 */
static List<String> formatTasks(Iterator<Entity> tasks) {
 List<String> strings = new ArrayList<>();
 while (tasks.hasNext()) {
  Entity task = tasks.next();
  if (task.getBoolean("done")) {
   strings.add(
     String.format("%d : %s (done)", task.getKey().getId(), task.getString("description")));
  } else {
   strings.add(String.format("%d : %s (created %s)", task.getKey().getId(),
     task.getString("description"), task.getTimestamp("created")));
  }
 }
 return strings;
}

代码示例来源:origin: spotify/styx

/**
 * Optionally get an {@link Instant} value for an {@link Entity}'s property.
 *
 * @return an optional containing the property value if it existed, empty otherwise.
 */
static Optional<Instant> getOptInstantProperty(Optional<Entity> entity, String property) {
 return entity
   .filter(w -> w.contains(property))
   .map(workflow -> timestampToInstant(workflow.getTimestamp(property)));
}

代码示例来源:origin: spotify/styx

Instant instant = timestampToInstant(entity.getTimestamp(PROPERTY_NEXT_NATURAL_TRIGGER));
final Instant triggerInstant;
 triggerInstant = timestampToInstant(entity.getTimestamp(PROPERTY_NEXT_NATURAL_OFFSET_TRIGGER));

代码示例来源:origin: spotify/styx

static Backfill entityToBackfill(Entity entity) throws IOException {
 final WorkflowId workflowId = WorkflowId.create(entity.getString(PROPERTY_COMPONENT),
                         entity.getString(PROPERTY_WORKFLOW));
 final BackfillBuilder builder = Backfill.newBuilder()
   .id(entity.getKey().getName())
   .start(timestampToInstant(entity.getTimestamp(PROPERTY_START)))
   .end(timestampToInstant(entity.getTimestamp(PROPERTY_END)))
   .workflowId(workflowId)
   .concurrency((int) entity.getLong(PROPERTY_CONCURRENCY))
   .nextTrigger(timestampToInstant(entity.getTimestamp(PROPERTY_NEXT_TRIGGER)))
   .schedule(Schedule.parse(entity.getString(PROPERTY_SCHEDULE)))
   .allTriggered(entity.getBoolean(PROPERTY_ALL_TRIGGERED))
   .halted(entity.getBoolean(PROPERTY_HALTED))
   .reverse(read(entity, PROPERTY_REVERSE, Boolean.FALSE));
 if (entity.contains(PROPERTY_DESCRIPTION)) {
  builder.description(entity.getString(PROPERTY_DESCRIPTION));
 }
 if (entity.contains(PROPERTY_TRIGGER_PARAMETERS)) {
  builder.triggerParameters(OBJECT_MAPPER.readValue(
    entity.getString(PROPERTY_TRIGGER_PARAMETERS), TriggerParameters.class));
 }
 return builder.build();
}

相关文章