Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java
index 428a6b959c..93710299b4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java
@@ -14,6 +14,8 @@ package org.eclipse.jgit.lib;
import java.io.Serializable;
import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.ZoneId;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
@@ -206,6 +208,20 @@ public class PersonIdent implements Serializable {
}
/**
+ * Copy a {@link org.eclipse.jgit.lib.PersonIdent}, but alter the clone's
+ * time stamp
+ *
+ * @param pi
+ * original {@link org.eclipse.jgit.lib.PersonIdent}
+ * @param aWhen
+ * local time as Instant
+ * @since 6.1
+ */
+ public PersonIdent(PersonIdent pi, Instant aWhen) {
+ this(pi.getName(), pi.getEmailAddress(), aWhen.toEpochMilli(), pi.tzOffset);
+ }
+
+ /**
* Construct a PersonIdent from simple data
*
* @param aName a {@link java.lang.String} object.
@@ -222,6 +238,27 @@ public class PersonIdent implements Serializable {
}
/**
+ * Construct a PersonIdent from simple data
+ *
+ * @param aName
+ * a {@link java.lang.String} object.
+ * @param aEmailAddress
+ * a {@link java.lang.String} object.
+ * @param aWhen
+ * local time stamp
+ * @param zoneId
+ * time zone id
+ * @since 6.1
+ */
+ public PersonIdent(final String aName, String aEmailAddress, Instant aWhen,
+ ZoneId zoneId) {
+ this(aName, aEmailAddress, aWhen.toEpochMilli(),
+ TimeZone.getTimeZone(zoneId)
+ .getOffset(aWhen
+ .toEpochMilli()) / (60 * 1000));
+ }
+
+ /**
* Copy a PersonIdent, but alter the clone's time stamp
*
* @param pi
@@ -304,6 +341,16 @@ public class PersonIdent implements Serializable {
}
/**
+ * Get when attribute as instant
+ *
+ * @return timestamp
+ * @since 6.1
+ */
+ public Instant getWhenAsInstant() {
+ return Instant.ofEpochMilli(when);
+ }
+
+ /**
* Get this person's declared time zone
*
* @return this person's declared time zone; null if time zone is unknown.
@@ -313,6 +360,16 @@ public class PersonIdent implements Serializable {
}
/**
+ * Get the time zone id
+ *
+ * @return the time zone id
+ * @since 6.1
+ */
+ public ZoneId getZoneId() {
+ return getTimeZone().toZoneId();
+ }
+
+ /**
* Get this person's declared time zone as minutes east of UTC.
*
* @return this person's declared time zone as minutes east of UTC. If the

Back to the top