diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserTest.java index 98e84fed8..6b0632aef 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserTest.java @@ -76,6 +76,17 @@ public void yesterday() throws ParseException { Assert.assertEquals(cal.getTime(), parse); } + @Test + public void never() throws ParseException { + GregorianCalendar cal = new GregorianCalendar(SystemReader + .getInstance().getTimeZone(), SystemReader.getInstance() + .getLocale()); + Date parse = GitDateParser.parse("never", cal); + Assert.assertEquals(GitDateParser.NEVER, parse); + parse = GitDateParser.parse("never", null); + Assert.assertEquals(GitDateParser.NEVER, parse); + } + @Test public void now() throws ParseException { String dateStr = "2007-02-21 15:35:00 +0100"; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateParser.java index dc5c7fa56..f1743d4f1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateParser.java @@ -62,6 +62,12 @@ * understands. */ public class GitDateParser { + /** + * The Date representing never. Though this is a concrete value, most + * callers are adviced to avoid depending on the actual value. + */ + public static final Date NEVER = new Date(Long.MAX_VALUE); + // Since SimpleDateFormat instances are expensive to instantiate they should // be cached. Since they are also not threadsafe they are cached using // ThreadLocal. @@ -113,6 +119,7 @@ private ParseableSimpleDateFormat(String formatStr) { * relative formats (e.g. "yesterday") the caller can specify the reference * date. These types of strings can be parsed: *