如何从JGit RevCommit获取作者日期和提交日期

时间:2012-09-26 19:01:27

标签: git jgit

RevCommit 有一个getCommitTime()方法,但它返回int并且没有作者时间。如何从 RevCommit

获取作者和提交日期

1 个答案:

答案 0 :(得分:19)

像这样:

RevCommit commit = ...;

PersonIdent authorIdent = commit.getAuthorIdent();
Date authorDate = authorIdent.getWhen();
TimeZone authorTimeZone = authorIdent.getTimeZone();

PersonIdent committerIdent = commit.getCommitterIdent();
...

另见API documentation