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

The following examples show how to use com.google.cloud.Timestamp#ofTimeSecondsAndNanos() . 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: SpannerConverters.java    From spring-cloud-gcp with Apache License 2.0 2 votes vote down vote up
/**
 * A utility function to convert a {@link java.sql.Timestamp} value to the {@link Timestamp}.
 * @param timestamp the value to convert
 * @return the equivalent Timestamp value
 */
public static Timestamp toTimestamp(@NonNull java.sql.Timestamp timestamp) {
	long secs = Math.floorDiv(timestamp.getTime(), 1000L);
	return Timestamp.ofTimeSecondsAndNanos(secs, timestamp.getNanos());
}