aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2024-12-29 01:19:26 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2024-12-29 01:53:03 +0100
commit47c9574343a4a556108e2a5a1e4af8741cb65483 (patch)
tree181dcaa9f507b895ac6e09e524431afe2ba89302
parenta687ca50e1300565fbf13fdbf885558dba258773 (diff)
downloadjgit-47c9574343a4a556108e2a5a1e4af8741cb65483.tar.gz
jgit-47c9574343a4a556108e2a5a1e4af8741cb65483.zip
RevCommitParseTest: : use java.time instead of java.util.Date API
Change-Id: I6cf6ed64b4029001cb5908338b60385804eb9997
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
index 2955516af0..014ff928a8 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
@@ -23,7 +23,9 @@ import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
-import java.util.TimeZone;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.lib.CommitBuilder;
@@ -94,18 +96,17 @@ public class RevCommitParseTest extends RepositoryTestCase {
assertNotNull(cAuthor);
assertEquals(authorName, cAuthor.getName());
assertEquals(authorEmail, cAuthor.getEmailAddress());
- assertEquals((long) authorTime * 1000, cAuthor.getWhen().getTime());
- assertEquals(TimeZone.getTimeZone("GMT" + authorTimeZone),
- cAuthor.getTimeZone());
+ assertEquals(Instant.ofEpochSecond(authorTime),
+ cAuthor.getWhenAsInstant());
+ assertEquals(ZoneId.of(authorTimeZone), cAuthor.getZoneId());
final PersonIdent cCommitter = c.getCommitterIdent();
assertNotNull(cCommitter);
assertEquals(committerName, cCommitter.getName());
assertEquals(committerEmail, cCommitter.getEmailAddress());
- assertEquals((long) committerTime * 1000,
- cCommitter.getWhen().getTime());
- assertEquals(TimeZone.getTimeZone("GMT" + committerTimeZone),
- cCommitter.getTimeZone());
+ assertEquals(Instant.ofEpochSecond(committerTime),
+ cCommitter.getWhenAsInstant());
+ assertEquals(ZoneId.of(committerTimeZone), cCommitter.getZoneId());
}
private RevCommit create(String msg) throws Exception {
@@ -153,9 +154,13 @@ public class RevCommitParseTest extends RepositoryTestCase {
c.parseCanonical(rw, b.toString().getBytes(UTF_8));
}
assertEquals(
- new PersonIdent("", "a_u_thor@example.com", 1218123387000L, 7),
+ new PersonIdent("", "a_u_thor@example.com",
+ Instant.ofEpochMilli(1218123387000L),
+ ZoneOffset.ofHoursMinutes(0, 7)),
c.getAuthorIdent());
- assertEquals(new PersonIdent("", "", 1218123390000L, -5),
+ assertEquals(
+ new PersonIdent("", "", Instant.ofEpochMilli(1218123390000L),
+ ZoneOffset.ofHoursMinutes(0, -5)),
c.getCommitterIdent());
}