1919
2020import org .eclipse .jgit .lib .AnyObjectId ;
2121import org .eclipse .jgit .revwalk .RevTag ;
22+
2223import java .time .Instant ;
24+ import java .time .temporal .ChronoUnit ;
2325
2426public class DatedRevTag {
2527
@@ -28,11 +30,13 @@ public class DatedRevTag {
2830 public final Instant date ;
2931
3032 public DatedRevTag (RevTag tag ) {
31- this (tag .getId (), tag .getTagName (), (tag .getTaggerIdent () != null ) ? tag .getTaggerIdent ().getWhen ().toInstant () : Instant .now ());
33+ this (tag .getId (), tag .getTagName (), tag .getTaggerIdent () != null
34+ ? tag .getTaggerIdent ().getWhen ().toInstant ()
35+ : nowMinusYears (1900 ));
3236 }
3337
3438 public DatedRevTag (AnyObjectId id , String tagName ) {
35- this (id , tagName , Instant . now ( ));
39+ this (id , tagName , nowMinusYears ( 2000 ));
3640 }
3741
3842 public DatedRevTag (AnyObjectId id , String tagName , Instant date ) {
@@ -41,6 +45,11 @@ public DatedRevTag(AnyObjectId id, String tagName, Instant date) {
4145 this .date = date ;
4246 }
4347
48+ static Instant nowMinusYears (final int years ) {
49+ // Instant does not support operations using > DAYS
50+ return Instant .now ().minus (years * 365L , ChronoUnit .DAYS );
51+ }
52+
4453 @ Override
4554 public String toString () {
4655 return "DatedRevTag{" +
0 commit comments