Skip to content

Commit 54d9255

Browse files
authored
Merge pull request #295 from TreeBASE/copilot/fix-auxdata-test-failure
Replace deprecated Date.toGMTString() with SimpleDateFormat
2 parents 0ac0f51 + e6fe6e6 commit 54d9255

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

treebase-core/src/main/java/org/cipres/treebase/auxdata/AuxData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22

3-
43
package org.cipres.treebase.auxdata;
54

65
import java.text.ParseException;
@@ -13,6 +12,7 @@
1312
import java.util.List;
1413
import java.util.Map;
1514
import java.util.Set;
15+
import java.util.TimeZone;
1616

1717
import org.cipres.treebase.domain.TBPersistable;
1818
import org.cipres.treebase.domain.matrix.Matrix;
@@ -372,6 +372,7 @@ public Date getCreationDate() {
372372
}
373373
try {
374374
SimpleDateFormat ds = new SimpleDateFormat("M/d/yy KK:mm:ss");
375+
ds.setTimeZone(TimeZone.getTimeZone("EST"));
375376
return ds.parse(creationDateString);
376377
} catch (ParseException e) { /* ignore it */ }
377378
return null;

treebase-core/src/test/java/org/cipres/treebase/auxdata/AuxDataTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
import java.io.IOException;
77
import java.io.UnsupportedEncodingException;
88
import java.net.URISyntaxException;
9+
import java.text.DateFormat;
10+
import java.text.SimpleDateFormat;
911
import java.util.Collection;
1012
import java.util.Date;
1113
import java.util.HashSet;
1214
import java.util.Iterator;
1315
import java.util.Map;
1416
import java.util.Set;
17+
import java.util.TimeZone;
1518

1619
import junit.framework.TestCase;
1720

@@ -156,10 +159,9 @@ public void testGetCreationHistorySection() {
156159

157160
public void testGetCreationDate() {
158161
Date d = aux.getCreationDate();
159-
// DateFormat df = new SimpleDateFormat("dd MMM yyyy hh:mm:ss zzz");
160-
// df.setTimeZone(TimeZone.getTimeZone("GMT"));
161-
// assertEquals("28 Jan 1996 19:14:16 GMT", df.format(d));
162-
assertEquals("28 Jan 1996 19:14:16 GMT", d.toGMTString());
162+
DateFormat df = new SimpleDateFormat("dd MMM yyyy HH:mm:ss zzz");
163+
df.setTimeZone(TimeZone.getTimeZone("GMT"));
164+
assertEquals("28 Jan 1996 19:14:16 GMT", df.format(d));
163165
}
164166

165167
public void testSkip() {

0 commit comments

Comments
 (0)