本文整理汇总了Java中com.google.protobuf.Timestamp类的典型用法代码示例。如果您正苦于以下问题:Java Timestamp类的具体用法?Java Timestamp怎么用?Java Timestamp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Timestamp类属于com.google.protobuf包,在下文中一共展示了Timestamp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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();
}
示例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());
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}