Skip to content

Commit aff7cf7

Browse files
committed
---
yaml --- r: 5867 b: refs/heads/tswast-patch-1 c: 0d44125 h: refs/heads/master i: 5865: d316368 5863: 06c8d05
1 parent ab40b64 commit aff7cf7

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: dd656b6ed809b0e16c4669cd5ae92f481c30f591
60+
refs/heads/tswast-patch-1: 0d4412540e535b955b2879911808c84808c2874d
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/src/main/java/com/google/gcloud/datastore/DateTime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public Calendar toCalendar() {
7878
}
7979

8080
public static DateTime now() {
81-
return new DateTime(System.nanoTime() / 1000L);
81+
return copyFrom(new Date());
8282
}
8383

8484
public static DateTime copyFrom(Date date) {

branches/tswast-patch-1/src/test/java/com/google/gcloud/datastore/DateTimeTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package com.google.gcloud.datastore;import static org.junit.Assert.assertEquals;import static org.junit.Assert.assertNotEquals;import static org.junit.Assert.assertTrue;import org.junit.Test;import java.util.Calendar;public class DateTimeTest { @Test public void testTimestampMicroseconds() throws Exception { Calendar cal = Calendar.getInstance(); DateTime date = DateTime.copyFrom(cal); assertEquals(cal.getTimeInMillis() * 1000, date.timestampMicroseconds()); } @Test public void testTimestampMillis() throws Exception { Calendar cal = Calendar.getInstance(); DateTime date = DateTime.copyFrom(cal); assertEquals(cal.getTimeInMillis(), date.timestampMillis()); } @Test public void testToDate() throws Exception { Calendar cal = Calendar.getInstance(); DateTime date = DateTime.copyFrom(cal); assertEquals(cal.getTime(), date.toDate()); } @Test public void testToCalendar() throws Exception { Calendar cal = Calendar.getInstance(); DateTime date = DateTime.copyFrom(cal); assertEquals(cal, date.toCalendar()); } @Test public void testNow() throws Exception { Calendar cal1 = Calendar.getInstance(); DateTime now = DateTime.now(); Calendar cal2 = Calendar.getInstance(); assertTrue(now.timestampMillis() >= cal1.getTimeInMillis()); assertTrue(now.timestampMillis() <= cal2.getTimeInMillis()); } @Test public void testCopyFrom() throws Exception { Calendar cal = Calendar.getInstance(); DateTime date1 = DateTime.copyFrom(cal); DateTime date2 = DateTime.copyFrom(cal.getTime()); cal.add(Calendar.DATE, 1); DateTime date3 = DateTime.copyFrom(cal.getTime()); assertEquals(date1, date2); assertNotEquals(date1, date3); }}

0 commit comments

Comments
 (0)