com.google.cloud.Timestamp.toString()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(154)

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

Timestamp.toString介绍

暂无

代码示例

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

@Override
public String toString() {
 return toString(new StringBuilder()).toString();
}

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

StringBuilder toString(StringBuilder b) {
 // TODO(user): Convert all internal toString(StringBuilder) methods to return StringBuilder.
 switch (mode) {
  case STRONG:
   return b.append("strong");
  case READ_TIMESTAMP:
   return b.append("exact_timestamp: ").append(timestamp.toString());
  case MIN_READ_TIMESTAMP:
   return b.append("min_read_timestamp: ").append(timestamp.toString());
  case EXACT_STALENESS:
   return b.append("exact_staleness: ").append(Durations.toString(staleness));
  case MAX_STALENESS:
   return b.append("max_staleness: ").append(Durations.toString(staleness));
  default:
   throw new AssertionError("Unexpected mode: " + mode);
 }
}

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

static Map<String, AttributeValue> getTransactionAnnotations(Transaction t) {
 return ImmutableMap.of(
   "Id",
   AttributeValue.stringAttributeValue(t.getId().toStringUtf8()),
   "Timestamp",
   AttributeValue.stringAttributeValue(Timestamp.fromProto(t.getReadTimestamp()).toString()));
}

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

@Test
public void testToString() {
 assertThat(Timestamp.MIN_VALUE.toString()).isEqualTo("0001-01-01T00:00:00Z");
 assertThat(Timestamp.MAX_VALUE.toString()).isEqualTo("9999-12-31T23:59:59.999999999Z");
 assertThat(Timestamp.ofTimeSecondsAndNanos(0, 0).toString()).isEqualTo("1970-01-01T00:00:00Z");
 assertThat(Timestamp.ofTimeSecondsAndNanos(0, 100).toString())
   .isEqualTo("1970-01-01T00:00:00.000000100Z");
 assertThat(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 0).toString())
   .isEqualTo(TEST_TIME_ISO);
}

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

ListValue toProto() {
  ListValue.Builder builder = ListValue.newBuilder();
  for (Object part : parts) {
   if (part == null) {
    builder.addValues(NULL_PROTO);
   } else if (part instanceof Boolean) {
    builder.addValuesBuilder().setBoolValue((Boolean) part);
   } else if (part instanceof Long) {
    builder.addValuesBuilder().setStringValue(part.toString());
   } else if (part instanceof Double) {
    builder.addValuesBuilder().setNumberValue((Double) part);
   } else if (part instanceof String) {
    builder.addValuesBuilder().setStringValue((String) part);
   } else if (part instanceof ByteArray) {
    builder.addValuesBuilder().setStringValue(((ByteArray) part).toBase64());
   } else if (part instanceof Timestamp) {
    builder.addValuesBuilder().setStringValue(((Timestamp) part).toString());
   } else {
    throw new AssertionError("Illegal key part: " + part.getClass());
   }
  }
  return builder.build();
 }
}

代码示例来源:origin: com.google.cloud/google-cloud-core

@Override
public String toString() {
 return toString(new StringBuilder()).toString();
}

代码示例来源:origin: com.google.cloud/google-cloud-spanner

StringBuilder toString(StringBuilder b) {
 // TODO(user): Convert all internal toString(StringBuilder) methods to return StringBuilder.
 switch (mode) {
  case STRONG:
   return b.append("strong");
  case READ_TIMESTAMP:
   return b.append("exact_timestamp: ").append(timestamp.toString());
  case MIN_READ_TIMESTAMP:
   return b.append("min_read_timestamp: ").append(timestamp.toString());
  case EXACT_STALENESS:
   return b.append("exact_staleness: ").append(Durations.toString(staleness));
  case MAX_STALENESS:
   return b.append("max_staleness: ").append(Durations.toString(staleness));
  default:
   throw new AssertionError("Unexpected mode: " + mode);
 }
}

代码示例来源:origin: com.google.cloud/google-cloud-spanner

static Map<String, AttributeValue> getTransactionAnnotations(Transaction t) {
 return ImmutableMap.of(
   "Id",
   AttributeValue.stringAttributeValue(t.getId().toStringUtf8()),
   "Timestamp",
   AttributeValue.stringAttributeValue(Timestamp.fromProto(t.getReadTimestamp()).toString()));
}

代码示例来源:origin: GoogleCloudPlatform/DataflowTemplates

builder.set(field, nullValue ? null : row.getString(fieldName));
} else if (spannerType.equals("TIMESTAMP")) {
 builder.set(field, nullValue ? null : row.getTimestamp(fieldName).toString());
} else if (spannerType.equals("DATE")) {
 builder.set(field, nullValue ? null : row.getDate(fieldName).toString());
        row.getTimestampList(fieldName)
          .stream()
          .map(timestamp -> timestamp == null ? null : timestamp.toString())
          .collect(Collectors.toList());
      builder.set(field, values);

代码示例来源:origin: GoogleCloudPlatform/DataflowTemplates

case TIMESTAMP:
 return nullSafeColumnParser(
   (currentRow, columnName) -> currentRow.getTimestamp(columnName).toString());
case ARRAY:
 return nullSafeColumnParser(SpannerConverters::parseArrayValue);

代码示例来源:origin: com.google.cloud/google-cloud-spanner

ListValue toProto() {
  ListValue.Builder builder = ListValue.newBuilder();
  for (Object part : parts) {
   if (part == null) {
    builder.addValues(NULL_PROTO);
   } else if (part instanceof Boolean) {
    builder.addValuesBuilder().setBoolValue((Boolean) part);
   } else if (part instanceof Long) {
    builder.addValuesBuilder().setStringValue(part.toString());
   } else if (part instanceof Double) {
    builder.addValuesBuilder().setNumberValue((Double) part);
   } else if (part instanceof String) {
    builder.addValuesBuilder().setStringValue((String) part);
   } else if (part instanceof ByteArray) {
    builder.addValuesBuilder().setStringValue(((ByteArray) part).toBase64());
   } else if (part instanceof Timestamp) {
    builder.addValuesBuilder().setStringValue(((Timestamp) part).toString());
   } else {
    throw new AssertionError("Illegal key part: " + part.getClass());
   }
  }
  return builder.build();
 }
}

相关文章