linquize linquize - 2 months ago 17
Git Question

JGit get timezone of a commit

In JGit, how to get timezone of a commit?
Current RevCommit class does not have anything about timezone.
It only returns UTC unix time


Use the PersonIdent:

RevCommit commit = ...;
PersonIdent committerIdent = commit.getCommitterIdent();
if (committerIdent != null) {
    TimeZone timeZone = committerIdent.getTimeZone(); // or getTimeZoneOffset()

There is also getAuthorIdent() which is the same for author.