Git 提交 Object 作者和提交者字段

Git Commit Object Author and Commiter Fields

我正在尝试使用 Java 创建一个在 Linux 机器上运行的服务器,我希望我的服务器以类似于 Git 的方式支持 Git ]中心。我想出了很多办法来实现这一目标,但有一件事我想知道...

假设我将以下 Git object(带有 header)放气并存储在文件系统中。

tree d35e45b7a3ec1bfd4d91b87c16d08fc4effc6dba
parent 385f73f0f5d38c6258a7d55038c9ceb24cd63157
author ThePyroEagle <exampleEmail@example.com> 1418335844 +0000
commiter ThePyroEagle <exampleEmail@example.com> 1418335844 +0000

最后的“1418335844+0000”是什么意思?

我认为这可能是以毫秒为单位的时间戳,但是当我解析它时,我使用以下代码得到了“1970 年 1 月 17 日”。

Date date = new Date(1418335844L);
System.out.printf("Current Time: %s\n",
        (new SimpleDateFormat("dd MMMM yyyy")).format(date));

无论这可能是什么,我将如何解析它?

这是一个以秒为单位的时间戳:2014-12-11T22:10:44+00:00。

git commit date format 状态:

Git内部格式

It is <unix timestamp> <time zone offset>, where:

  • <unix timestamp> is the number of seconds since the UNIX epoch.
  • <time zone offset> is a positive or negative offset from UTC. For example CET (which is 2 hours ahead UTC) is +0200.

参见:

  • Epoch converter:1418335844 => 2014 年 12 月 11 日,星期四 22:10:44 GMT
  • "convert epoch time to date"
  • "Java: Date from unix timestamp"