linquize linquize - 1 year ago 88
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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download