public class GitDateParser extends Object
Date
.
When git needs to parse strings specified by the user this parser can be
used. One example is the parsing of the config parameter gc.pruneexpire. The
parser can handle only subset of what native gits approxidate parser
understands.Modifier and Type | Field and Description |
---|---|
static Date |
NEVER
The Date representing never.
|
Constructor and Description |
---|
GitDateParser() |
Modifier and Type | Method and Description |
---|---|
static Date |
parse(String dateStr,
Calendar now)
Parses a string into a
Date using the default locale. |
static Date |
parse(String dateStr,
Calendar now,
Locale locale)
Parses a string into a
Date using the given locale. |
public static final Date NEVER
public static Date parse(String dateStr, Calendar now) throws ParseException
Date
using the default locale.
Since this parser also supports relative formats (e.g. "yesterday") the
caller can specify the reference date. These types of strings can be
parsed:
dateStr
- the string to be parsednow
- the base date which is used for the calculation of relative
formats. E.g. if baseDate is "25.8.2012" then parsing of the
string "1 week ago" would result in a date corresponding to
"18.8.2012". This is used when a JGit command calls this
parser often but wants a consistent starting point for
calls.null
then the current time will be used
instead.Date
ParseException
- if the given dateStr was not recognizedpublic static Date parse(String dateStr, Calendar now, Locale locale) throws ParseException
Date
using the given locale.
Since this parser also supports relative formats (e.g. "yesterday") the
caller can specify the reference date. These types of strings can be
parsed:
dateStr
- the string to be parsednow
- the base date which is used for the calculation of relative
formats. E.g. if baseDate is "25.8.2012" then parsing of the
string "1 week ago" would result in a date corresponding to
"18.8.2012". This is used when a JGit command calls this
parser often but wants a consistent starting point for
calls.null
then the current time will be used
instead.locale
- locale to be used to parse the date stringDate
ParseException
- if the given dateStr was not recognizedCopyright © 2020 Eclipse JGit Project. All rights reserved.