public class DateUtil extends Object
Modifier and Type | Field and Description |
---|---|
static Collection<String> |
DEFAULT_DATE_FORMATS
A suite of default date formats that can be parsed, and thus transformed to the Solr specific format
|
static String |
PATTERN_ASCTIME
Date format pattern used to parse HTTP date headers in ANSI C
asctime() format. |
static String |
PATTERN_RFC1036
Date format pattern used to parse HTTP date headers in RFC 1036 format.
|
static String |
PATTERN_RFC1123
Date format pattern used to parse HTTP date headers in RFC 1123 format.
|
static TimeZone |
UTC |
Constructor and Description |
---|
DateUtil() |
Modifier and Type | Method and Description |
---|---|
static Calendar |
formatDate(Date date,
Calendar cal,
Appendable out)
Formats the date and returns the calendar instance that was used (which may be reused)
|
static DateFormat |
getThreadLocalDateFormat()
Returns a formatter that can be use by the current thread if needed to
convert Date objects to the Internal representation.
|
static Date |
parseDate(String d)
Returns a formatter that can be use by the current thread if needed to
convert Date objects to the Internal representation.
|
static Date |
parseDate(String d,
Collection<String> fmts) |
static Date |
parseDate(String dateValue,
Collection<String> dateFormats,
Date startDate)
Slightly modified from org.apache.commons.httpclient.util.DateUtil.parseDate
|
public static final String PATTERN_RFC1123
public static final String PATTERN_RFC1036
public static final String PATTERN_ASCTIME
asctime()
format.public static final Collection<String> DEFAULT_DATE_FORMATS
public static TimeZone UTC
public static Date parseDate(String d) throws ParseException
d
- The input date to parseDate
ParseException
- If the input can't be parsedpublic static Date parseDate(String d, Collection<String> fmts) throws ParseException
ParseException
public static Date parseDate(String dateValue, Collection<String> dateFormats, Date startDate) throws ParseException
Parses the date value using the given date formats.
dateValue
- the date value to parsedateFormats
- the date formats to usestartDate
- During parsing, two digit years will be placed in the range
startDate
to startDate + 100 years
. This value may
be null
. When null
is given as a parameter, year
2000
will be used.ParseException
- if none of the dataFormats could parse the dateValuepublic static DateFormat getThreadLocalDateFormat()
DateFormat
for the current threadpublic static Calendar formatDate(Date date, Calendar cal, Appendable out) throws IOException
IOException
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.