linquize linquize - 1 month ago 13
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

Answer

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.

Comments