Java Code Examples for com.google.cloud.Timestamp#of()

The following examples show how to use com.google.cloud.Timestamp#of() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConceptsTest.java    From java-docs-samples with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes Datastore and cleans out any residual values.  Also initializes global variables
 * used for testing.
 */
@Before
public void setUp() {
  datastore = HELPER.getOptions().toBuilder().setNamespace("ghijklmnop").build().getService();
  StructuredQuery<Key> query = Query.newKeyQueryBuilder().build();
  QueryResults<Key> result = datastore.run(query);
  datastore.delete(Iterators.toArray(result, Key.class));
  keyFactory = datastore.newKeyFactory().setKind("Task");
  taskKey = keyFactory.newKey("some-arbitrary-key");
  testEntity = Entity.newBuilder(taskKey, TEST_FULL_ENTITY).build();
  Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
  calendar.set(1990, JANUARY, 1);
  startDate = Timestamp.of(calendar.getTime());
  calendar.set(2000, JANUARY, 1);
  endDate = Timestamp.of(calendar.getTime());
  calendar.set(1999, DECEMBER, 31);
  includedDate = Timestamp.of(calendar.getTime());
}
 
Example 2
Source File: DatastoreStorage.java    From styx with Apache License 2.0 4 votes vote down vote up
static Timestamp instantToTimestamp(Instant instant) {
  return Timestamp.of(Date.from(instant));
}
 
Example 3
Source File: QueryUtils.java    From catatumbo with Apache License 2.0 2 votes vote down vote up
/**
 * Converts the given Calendar to a Timestamp.
 * 
 * @param calendar
 *          the Calendar to convert
 * @return Timestamp object that is equivalent to the given Calendar.
 */
private static Timestamp toTimestamp(Calendar calendar) {
  return Timestamp.of(calendar.getTime());
}
 
Example 4
Source File: QueryUtils.java    From catatumbo with Apache License 2.0 2 votes vote down vote up
/**
 * Converts the given Date to a Timestamp.
 * 
 * @param date
 *          the Date to convert
 * @return Timestamp object that is equivalent to the given Date.
 */
private static Timestamp toTimestamp(Date date) {
  return Timestamp.of(date);
}