This repository was archived by the owner on Dec 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
google-cloud-core/src/test/java/com/google/cloud Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,30 @@ public void ofDate() {
80
80
assertThat (timestamp .getNanos ()).isEqualTo (expectedNanos );
81
81
}
82
82
83
+ @ Test
84
+ public void ofSqlTimestamp () {
85
+ String expectedTimestamp = "1970-01-01T00:00:12.345000000Z" ;
86
+ java .sql .Timestamp input = new java .sql .Timestamp (12345 );
87
+ Timestamp timestamp = Timestamp .of (input );
88
+ assertThat (timestamp .toString ()).isEqualTo (expectedTimestamp );
89
+ }
90
+
91
+ @ Test
92
+ public void ofSqlTimestampPreEpoch () {
93
+ String expectedTimestamp = "1969-12-31T23:59:47.655000000Z" ;
94
+ java .sql .Timestamp input = new java .sql .Timestamp (-12345 );
95
+ Timestamp timestamp = Timestamp .of (input );
96
+ assertThat (timestamp .toString ()).isEqualTo (expectedTimestamp );
97
+ }
98
+
99
+ @ Test
100
+ public void ofSqlTimestampOnEpoch () {
101
+ String expectedTimestamp = "1970-01-01T00:00:00Z" ;
102
+ java .sql .Timestamp input = new java .sql .Timestamp (0 );
103
+ Timestamp timestamp = Timestamp .of (input );
104
+ assertThat (timestamp .toString ()).isEqualTo (expectedTimestamp );
105
+ }
106
+
83
107
@ Test
84
108
public void ofDatePreEpoch () {
85
109
Timestamp timestamp = Timestamp .of (TEST_DATE_PRE_EPOCH );
You can’t perform that action at this time.
0 commit comments