• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Timestamp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.protobuf.Timestamp的典型用法代码示例。如果您正苦于以下问题:Java Timestamp类的具体用法?Java Timestamp怎么用?Java Timestamp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Timestamp类属于com.google.protobuf包,在下文中一共展示了Timestamp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testEntityBQTransform_toTableRow_timestamp

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
public void testEntityBQTransform_toTableRow_timestamp() throws IOException {
  Entity e;

  EntityBQTransform strictEbt = EntityBQTransform.newBuilder()
      .setStrictCast(true)
      .setRowSchema(exampleTable().getFields())
      .build();

  EntityBQTransform nonstrictEbt = EntityBQTransform.newBuilder()
      .setStrictCast(false)
      .setRowSchema(exampleTable().getFields())
      .build();

  e = Entity.newBuilder()
      .putProperties("birthTimestamp", Value.newBuilder().setTimestampValue(
          Timestamp.newBuilder().setNanos(1000).setSeconds(1498692500).build()).build())
      .build();

  Assert.assertEquals("2017-06-28T23:28:20.000001Z", strictEbt.toTableRow(e).get("birthTimestamp"));
  Assert.assertEquals("2017-06-28T23:28:20.000001Z", nonstrictEbt.toTableRow(e).get("birthTimestamp"));
}
 
开发者ID:cobookman,项目名称:teleport,代码行数:23,代码来源:EntityBQTransformTest.java


示例2: testEntityBQTransform_toTableRow_date

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
public void testEntityBQTransform_toTableRow_date() throws IOException {
  Entity e;

  EntityBQTransform strictEbt = EntityBQTransform.newBuilder()
      .setStrictCast(true)
      .setRowSchema(exampleTable().getFields())
      .build();

  EntityBQTransform nonstrictEbt = EntityBQTransform.newBuilder()
      .setStrictCast(false)
      .setRowSchema(exampleTable().getFields())
      .build();

  e = Entity.newBuilder()
      .putProperties("birthDate", Value.newBuilder().setTimestampValue(
          Timestamp.newBuilder().setNanos(1000).setSeconds(1498692500).build()).build())
      .build();

  Assert.assertEquals("2017-06-28", strictEbt.toTableRow(e).get("birthDate"));
  Assert.assertEquals("2017-06-28", nonstrictEbt.toTableRow(e).get("birthDate"));
}
 
开发者ID:cobookman,项目名称:teleport,代码行数:23,代码来源:EntityBQTransformTest.java


示例3: testEntityBQTransform_toTableRow_time

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
public void testEntityBQTransform_toTableRow_time() throws IOException {
  Entity e;

  EntityBQTransform strictEbt = EntityBQTransform.newBuilder()
      .setStrictCast(true)
      .setRowSchema(exampleTable().getFields())
      .build();

  EntityBQTransform nonstrictEbt = EntityBQTransform.newBuilder()
      .setStrictCast(false)
      .setRowSchema(exampleTable().getFields())
      .build();

  e = Entity.newBuilder()
      .putProperties("birthTime", Value.newBuilder().setTimestampValue(
          Timestamp.newBuilder().setNanos(1000).setSeconds(1498692500).build()).build())
      .build();

  Assert.assertEquals("23:28:20.000001", strictEbt.toTableRow(e).get("birthTime"));
  Assert.assertEquals("23:28:20.000001", nonstrictEbt.toTableRow(e).get("birthTime"));
}
 
开发者ID:cobookman,项目名称:teleport,代码行数:23,代码来源:EntityBQTransformTest.java


示例4: testEntityBQTransform_toTableRow_datetime

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
public void testEntityBQTransform_toTableRow_datetime() throws IOException {
  Entity e;

  EntityBQTransform strictEbt = EntityBQTransform.newBuilder()
      .setStrictCast(true)
      .setRowSchema(exampleTable().getFields())
      .build();

  EntityBQTransform nonstrictEbt = EntityBQTransform.newBuilder()
      .setStrictCast(false)
      .setRowSchema(exampleTable().getFields())
      .build();

  e = Entity.newBuilder()
      .putProperties("birthDateTime", Value.newBuilder().setTimestampValue(
          Timestamp.newBuilder().setNanos(1000).setSeconds(1498692500).build()).build())
      .build();

  Assert.assertEquals("2017-06-28 23:28:20.000001", strictEbt.toTableRow(e).get("birthDateTime"));
  Assert.assertEquals("2017-06-28 23:28:20.000001", nonstrictEbt.toTableRow(e).get("birthDateTime"));
}
 
开发者ID:cobookman,项目名称:teleport,代码行数:23,代码来源:EntityBQTransformTest.java


示例5: fromInstantUtc

import com.google.protobuf.Timestamp; //导入依赖的package包/类
public static Timestamp fromInstantUtc(@Nonnull Instant instant) {
    checkNotNull(instant, "instant");
    return Timestamp.newBuilder()
            .setSeconds(instant.getEpochSecond())
            .setNanos(instant.getNano())
            .build();
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:8,代码来源:MoreTimestamps.java


示例6: testSingleClientRemoteSpan

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
public void testSingleClientRemoteSpan() {
	Span parent = Span.builder()
			.traceId(123L)
			.name("http:call")
			.begin(beginTime - 1)
			.end(endTime + 1)
			.log(new Log(beginTime, Span.CLIENT_SEND))
			.log(new Log(endTime, Span.CLIENT_RECV))
			.remote(true)
			.build();

	this.spanListener.report(parent);

	Assert.assertEquals(1, this.test.traceSpans.size());
	TraceSpan traceSpan = this.test.traceSpans.get(0);
	Assert.assertEquals("http:call", traceSpan.getName());
	// Client span chould use CS and CR time, not Span begin or end time.
	Assert.assertEquals(Timestamp.getDefaultInstance(), traceSpan.getStartTime());
	Assert.assertEquals(Timestamp.getDefaultInstance(), traceSpan.getEndTime());
	Assert.assertEquals(this.dateFormatter.format(new Date(beginTime)),
			traceSpan.getLabelsOrThrow("cloud.spring.io/cs"));
	Assert.assertEquals(this.dateFormatter.format(new Date(endTime)),
			traceSpan.getLabelsOrThrow("cloud.spring.io/cr"));
	Assert.assertEquals(TraceSpan.SpanKind.RPC_CLIENT, traceSpan.getKind());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:27,代码来源:StackdriverTraceSpanListenerTests.java


示例7: asOperation

import com.google.protobuf.Timestamp; //导入依赖的package包/类
/**
 * Returns the {@link Operation} instance corresponding to this instance.
 *
 * @param clock is used to determine the current timestamp
 *
 * @return a {@link Operation}
 */
public Operation asOperation(Clock clock) {
  Operation.Builder b = Operation.newBuilder();
  b.setImportance(Importance.LOW);
  Timestamp now = Timestamps.now(clock);
  b.setStartTime(now).setEndTime(now);
  if (!Strings.isNullOrEmpty(operationId)) {
    b.setOperationId(operationId);
  }
  if (!Strings.isNullOrEmpty(operationName)) {
    b.setOperationName(operationName);
  }
  String consumerId = getOperationConsumerId();
  if (!Strings.isNullOrEmpty(consumerId)) {
    b.setConsumerId(consumerId);
  }
  return b.build();
}
 
开发者ID:cloudendpoints,项目名称:endpoints-management-java,代码行数:25,代码来源:OperationInfo.java


示例8: thirdCase

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
@DisplayName("set all the optional fields")
void thirdCase() {
    final TaskCreationId pid = newPid();
    final TaskId taskId = newTaskId();
    testEnv.createDraft(pid, taskId);

    final String description = "thirdCase";
    final TaskPriority priority = LOW;
    final Timestamp dueDate = add(getCurrentTime(), fromSeconds(100));
    testEnv.setDetails(pid, description, priority, dueDate);
    final String labelTitle = "thirdCase-label";
    final LabelId labelId = testEnv.createNewLabel(labelTitle);
    testEnv.addLabel(pid, labelId);
    testEnv.complete(pid);

    final Task task = testEnv.taskById(taskId);
    assertEquals(description, task.getDescription().getValue());
    assertEquals(priority, task.getPriority());
    assertAssignedLabel(taskId, labelTitle, GRAY);
}
 
开发者ID:SpineEventEngine,项目名称:todo-list,代码行数:22,代码来源:TaskCreationWizardTest.java


示例9: createTask

import com.google.protobuf.Timestamp; //导入依赖的package包/类
/**
 * Creates a new task with the given details fields.
 *
 * <p>Sends the {@link CreateBasicTask} command through the {@linkplain #client() gRPC client}.
 *
 * @param description the new task description
 */
void createTask(String description, TaskPriority priority, Timestamp taskDueDate) {
    final TaskDescription taskDescription = TaskDescription.newBuilder()
                                                           .setValue(description)
                                                           .build();
    final SetTaskDetails command = SetTaskDetails.newBuilder()
                                                 .setId(wizardId)
                                                 .setDescription(taskDescription)
                                                 .setPriority(priority)
                                                 .setDueDate(taskDueDate)
                                                 .build();
    post(command);
    this.taskDescription = taskDescription;
    this.taskPriority = priority;
    this.taskDueDate = taskDueDate;
}
 
开发者ID:SpineEventEngine,项目名称:todo-list,代码行数:23,代码来源:NewTaskViewModel.java


示例10: getViewAfterUpdateTaskDueDate

import com.google.protobuf.Timestamp; //导入依赖的package包/类
private TaskItem getViewAfterUpdateTaskDueDate(Timestamp newDueDate, boolean isCorrectId) {
    final CreateDraft createDraft = createDraft();
    client.postCommand(createDraft);

    final TaskId createdTaskId = createDraft.getId();

    updateDueDate(newDueDate, isCorrectId, createdTaskId);

    final List<TaskItem> taskViews = client.getDraftTasksView()
                                           .getDraftTasks()
                                           .getItemsList();
    assertEquals(1, taskViews.size());

    final TaskItem view = taskViews.get(0);
    assertEquals(createdTaskId, view.getId());

    return view;
}
 
开发者ID:SpineEventEngine,项目名称:todo-list,代码行数:19,代码来源:UpdateTaskDueDateTest.java


示例11: setTaskDetails

import com.google.protobuf.Timestamp; //导入依赖的package包/类
/**
 * Creates commands setting the task details to the target task
 *
 * <p>This method is guaranteed to generate at least one command. Effectively, each non-default
 * field of the {@code SetTaskDetails} command causes a command to be generated.
 *
 * @param src the source command
 * @return new commands generated from the given {@code src} command
 */
Collection<? extends TodoCommand> setTaskDetails(SetTaskDetails src) {
    final ImmutableSet.Builder<TodoCommand> commands = ImmutableSet.builder();
    final TaskDescription description = src.getDescription();
    final TodoCommand updateDescription = updateTaskDescription(description);
    commands.add(updateDescription);
    final TaskPriority priority = src.getPriority();
    if (enumIsNotDefault(priority)) {
        final TodoCommand updatePriority = updateTaskPriority(priority);
        commands.add(updatePriority);
    }
    final Timestamp dueDate = src.getDueDate();
    if (isNotDefault(dueDate)) {
        final TodoCommand updateDueDate = updateTaskDueDate(dueDate);
        commands.add(updateDueDate);
    }
    return commands.build();
}
 
开发者ID:SpineEventEngine,项目名称:todo-list,代码行数:27,代码来源:WizardCommands.java


示例12: produceEvent

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
@DisplayName("produce TaskDueDateUpdated event")
void produceEvent() {
    final UpdateTaskDueDate updateTaskDueDateCmd = updateTaskDueDateInstance(taskId);
    final List<? extends Message> messageList =
            dispatchCommand(aggregate, envelopeOf(updateTaskDueDateCmd));
    assertEquals(1, messageList.size());
    assertEquals(TaskDueDateUpdated.class, messageList.get(0)
                                                      .getClass());

    final TaskDueDateUpdated taskDueDateUpdated = (TaskDueDateUpdated) messageList.get(0);
    assertEquals(taskId, taskDueDateUpdated.getTaskId());
    final Timestamp newDueDate = taskDueDateUpdated.getDueDateChange()
                                                   .getNewValue();
    assertEquals(DUE_DATE, newDueDate);
}
 
开发者ID:SpineEventEngine,项目名称:todo-list,代码行数:17,代码来源:UpdateTaskDueDateTest.java


示例13: updateDueDate

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
@DisplayName("update the task due date in DraftTaskItem")
void updateDueDate() {
    final TaskDraftCreated taskDraftCreatedEvent = taskDraftCreatedInstance();
    dispatch(projection, createEvent(taskDraftCreatedEvent));

    final Timestamp updatedDueDate = getCurrentTime();
    final TaskId expectedTaskId = taskDraftCreatedEvent.getId();

    final TaskDueDateUpdated taskDueDateUpdatedEvent =
            taskDueDateUpdatedInstance(expectedTaskId, updatedDueDate);
    dispatch(projection, createEvent(taskDueDateUpdatedEvent));

    final TaskListView taskListView = projection.getState()
                                                .getDraftTasks();
    assertEquals(1, taskListView.getItemsCount());

    final TaskItem taskView = taskListView.getItemsList()
                                          .get(0);
    assertEquals(expectedTaskId, taskView.getId());
    assertEquals(updatedDueDate, taskView.getDueDate());
}
 
开发者ID:SpineEventEngine,项目名称:todo-list,代码行数:23,代码来源:DraftTasksViewProjectionTest.java


示例14: notUpdate

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
@DisplayName("not update the task due date by wrong task ID")
void notUpdate() {
    taskDraftCreated();

    final Timestamp updatedDueDate = getCurrentTime();

    final TaskDueDateUpdated taskDueDateUpdatedEvent =
            taskDueDateUpdatedInstance(TaskId.getDefaultInstance(), updatedDueDate);
    dispatch(projection, createEvent(taskDueDateUpdatedEvent));

    final TaskListView taskListView = projection.getState()
                                                .getDraftTasks();
    assertEquals(1, taskListView.getItemsCount());

    final TaskItem taskView = taskListView.getItemsList()
                                          .get(0);
    assertEquals(TASK_ID, taskView.getId());
    assertNotEquals(updatedDueDate, taskView.getDueDate());
}
 
开发者ID:SpineEventEngine,项目名称:todo-list,代码行数:21,代码来源:DraftTasksViewProjectionTest.java


示例15: updateDueDate

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
@DisplayName("update the task due date on MyListView")
void updateDueDate() {
    final TaskCreated taskCreatedEvent = taskCreatedInstance();
    dispatch(projection, createEvent(taskCreatedEvent));

    final Timestamp updatedDueDate = getCurrentTime();
    final TaskId expectedTaskId = taskCreatedEvent.getId();

    final TaskDueDateUpdated taskDueDateUpdatedEvent =
            taskDueDateUpdatedInstance(expectedTaskId, updatedDueDate);
    dispatch(projection, createEvent(taskDueDateUpdatedEvent));

    final TaskListView taskListView = projection.getState()
                                                .getMyList();
    assertEquals(1, taskListView.getItemsCount());

    final TaskItem taskView = taskListView.getItemsList()
                                          .get(0);
    assertEquals(expectedTaskId, taskView.getId());
    assertEquals(updatedDueDate, taskView.getDueDate());
}
 
开发者ID:SpineEventEngine,项目名称:todo-list,代码行数:23,代码来源:MyListViewProjectionTest.java


示例16: doeNotUpdateDueDate

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
@DisplayName("not update the task due date in MyListView by wrong task ID")
void doeNotUpdateDueDate() {
    final TaskCreated taskCreatedEvent = taskCreatedInstance();
    dispatch(projection, createEvent(taskCreatedEvent));

    final Timestamp updatedDueDate = getCurrentTime();

    final TaskDueDateUpdated taskDueDateUpdatedEvent =
            taskDueDateUpdatedInstance(TaskId.getDefaultInstance(), updatedDueDate);
    dispatch(projection, createEvent(taskDueDateUpdatedEvent));

    final TaskListView taskListView = projection.getState()
                                                .getMyList();
    assertEquals(1, taskListView.getItemsCount());

    final TaskItem taskView = taskListView.getItemsList()
                                          .get(0);
    assertNotEquals(updatedDueDate, taskView.getDueDate());
}
 
开发者ID:SpineEventEngine,项目名称:todo-list,代码行数:21,代码来源:MyListViewProjectionTest.java


示例17: createChannelHeader

import com.google.protobuf.Timestamp; //导入依赖的package包/类
/**
 * createChannelHeader create chainHeader
 *
 * @param type                     header type. See {@link ChannelHeader.Builder#setType}.
 * @param txID                     transaction ID. See {@link ChannelHeader.Builder#setTxId}.
 * @param channelID                channel ID. See {@link ChannelHeader.Builder#setChannelId}.
 * @param epoch                    the epoch in which this header was generated. See {@link ChannelHeader.Builder#setEpoch}.
 * @param timeStamp                local time when the message was created. See {@link ChannelHeader.Builder#setTimestamp}.
 * @param chaincodeHeaderExtension extension to attach dependent on the header type. See {@link ChannelHeader.Builder#setExtension}.
 * @return a new chain header.
 */
public static ChannelHeader createChannelHeader(HeaderType type, String txID, String channelID, long epoch, Timestamp timeStamp, ChaincodeHeaderExtension chaincodeHeaderExtension) {

    if (isDebugLevel) {
        logger.debug(format("ChannelHeader: type: %s, version: 1, Txid: %s, channelId: %s, epoch %d",
                type.name(), txID, channelID, epoch));

    }

    ChannelHeader.Builder ret = ChannelHeader.newBuilder()
            .setType(type.getNumber())
            .setVersion(1)
            .setTxId(txID)
            .setChannelId(channelID)
            .setTimestamp(timeStamp)
            .setEpoch(epoch);
    if (null != chaincodeHeaderExtension) {
        ret.setExtension(chaincodeHeaderExtension.toByteString());
    }

    return ret.build();

}
 
开发者ID:hyperledger,项目名称:fabric-sdk-java,代码行数:34,代码来源:ProtoUtils.java


示例18: setSchedule

import com.google.protobuf.Timestamp; //导入依赖的package包/类
/**
 * Updates {@linkplain CommandContext.Schedule command schedule}.
 *
 * @param command        a command to update
 * @param delay          a {@linkplain CommandContext.Schedule#getDelay() delay} to set
 * @param schedulingTime the time when the command was scheduled by the {@code CommandScheduler}
 * @return an updated command
 */
static Command setSchedule(Command command, Duration delay, Timestamp schedulingTime) {
    checkNotNull(command);
    checkNotNull(delay);
    checkNotNull(schedulingTime);
    checkValid(schedulingTime);

    final CommandContext context = command.getContext();
    final CommandContext.Schedule scheduleUpdated = context.getSchedule()
                                                           .toBuilder()
                                                           .setDelay(delay)
                                                           .build();
    final CommandContext contextUpdated = context.toBuilder()
                                                 .setSchedule(scheduleUpdated)
                                                 .build();

    final Command.SystemProperties sysProps = command.getSystemProperties()
                                                     .toBuilder()
                                                     .setSchedulingTime(schedulingTime)
                                                     .build();
    final Command result = command.toBuilder()
                                  .setContext(contextUpdated)
                                  .setSystemProperties(sysProps)
                                  .build();
    return result;
}
 
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:34,代码来源:CommandScheduler.java


示例19: keep_multiple_filters_for_single_column

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
public void keep_multiple_filters_for_single_column() throws ParseException {
    final String columnName = "time";
    final EntityColumn column = mock(EntityColumn.class);

    // Some valid Timestamp values
    final Timestamp startTime = Timestamps.parse("2000-01-01T10:00:00.000-05:00");
    final Timestamp deadline = Timestamps.parse("2017-01-01T10:00:00.000-05:00");

    final ColumnFilter startTimeFilter = gt(columnName, startTime);
    final ColumnFilter deadlineFilter = le(columnName, deadline);
    final Multimap<EntityColumn, ColumnFilter> columnFilters =
            ImmutableMultimap.<EntityColumn, ColumnFilter>builder()
                             .put(column, startTimeFilter)
                             .put(column, deadlineFilter)
                             .build();
    final CompositeQueryParameter parameter = from(columnFilters, ALL);
    final QueryParameters parameters = newBuilder().add(parameter)
                                                   .build();
    final List<CompositeQueryParameter> aggregatingParameters = newArrayList(parameters);
    assertSize(1, aggregatingParameters);
    final Multimap<EntityColumn, ColumnFilter> actualColumnFilters = aggregatingParameters.get(0).getFilters();
    final Collection<ColumnFilter> timeFilters = actualColumnFilters.get(column);
    assertSize(2, timeFilters);
    assertContainsAll(timeFilters, startTimeFilter, deadlineFilter);
}
 
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:27,代码来源:QueryParametersShould.java


示例20: write_records_and_return_sorted_by_version_descending

import com.google.protobuf.Timestamp; //导入依赖的package包/类
@Test
public void write_records_and_return_sorted_by_version_descending() {
    final int eventsNumber = 5;
    final List<AggregateEventRecord> records = newLinkedList();
    final Timestamp timestamp = getCurrentTime();
    Version currentVersion = zero();
    for (int i = 0; i < eventsNumber; i++) {
        final Project state = Project.getDefaultInstance();
        final Event event = eventFactory.createEvent(state, currentVersion, timestamp);
        final AggregateEventRecord record = StorageRecord.create(timestamp, event);
        records.add(record);
        currentVersion = increment(currentVersion);
    }
    writeAll(id, records);

    final Iterator<AggregateEventRecord> iterator = historyBackward();
    final List<AggregateEventRecord> actual = newArrayList(iterator);
    reverse(records); // expected records should be in a reverse order
    assertEquals(records, actual);
}
 
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:21,代码来源:AggregateStorageShould.java



注:本文中的com.google.protobuf.Timestamp类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LongType类代码示例发布时间:2022-05-21
下一篇:
Java Cylinder类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap