public class DateUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
DateUtil.ThreadLocalDateFormat |
Modifier and Type | Field and Description |
---|---|
static java.util.Collection<java.lang.String> |
DEFAULT_DATE_FORMATS
A suite of default date formats that can be parsed, and thus transformed to the Solr specific format
|
private static java.util.Collection<java.lang.String> |
DEFAULT_HTTP_CLIENT_PATTERNS |
private static java.util.Date |
DEFAULT_TWO_DIGIT_YEAR_START |
private static DateUtil.ThreadLocalDateFormat |
fmtThreadLocal |
private static java.util.TimeZone |
GMT |
static java.lang.String |
PATTERN_ASCTIME
Date format pattern used to parse HTTP date headers in ANSI C
asctime() format. |
static java.lang.String |
PATTERN_RFC1036
Date format pattern used to parse HTTP date headers in RFC 1036 format.
|
static java.lang.String |
PATTERN_RFC1123
Date format pattern used to parse HTTP date headers in RFC 1123 format.
|
static java.util.TimeZone |
UTC |
Constructor and Description |
---|
DateUtil() |
Modifier and Type | Method and Description |
---|---|
static java.util.Calendar |
formatDate(java.util.Date date,
java.util.Calendar cal,
java.lang.Appendable out)
Formats the date and returns the calendar instance that was used (which may be reused)
|
static java.text.DateFormat |
getThreadLocalDateFormat()
Returns a formatter that can be use by the current thread if needed to
convert Date objects to the Internal representation.
|
static java.util.Date |
parseDate(java.lang.String d)
Returns a formatter that can be use by the current thread if needed to
convert Date objects to the Internal representation.
|
static java.util.Date |
parseDate(java.lang.String d,
java.util.Collection<java.lang.String> fmts) |
static java.util.Date |
parseDate(java.lang.String dateValue,
java.util.Collection<java.lang.String> dateFormats,
java.util.Date startDate)
Slightly modified from org.apache.commons.httpclient.util.DateUtil.parseDate
Parses the date value using the given date formats.
|
public static final java.lang.String PATTERN_RFC1123
public static final java.lang.String PATTERN_RFC1036
public static final java.lang.String PATTERN_ASCTIME
asctime()
format.private static final java.util.Collection<java.lang.String> DEFAULT_HTTP_CLIENT_PATTERNS
private static final java.util.Date DEFAULT_TWO_DIGIT_YEAR_START
private static final java.util.TimeZone GMT
public static final java.util.Collection<java.lang.String> DEFAULT_DATE_FORMATS
public static java.util.TimeZone UTC
private static DateUtil.ThreadLocalDateFormat fmtThreadLocal
public static java.util.Date parseDate(java.lang.String d) throws java.text.ParseException
d
- The input date to parseDate
java.text.ParseException
- If the input can't be parsedorg.apache.commons.httpclient.util.DateParseException
- If the input can't be parsedpublic static java.util.Date parseDate(java.lang.String d, java.util.Collection<java.lang.String> fmts) throws java.text.ParseException
java.text.ParseException
public static java.util.Date parseDate(java.lang.String dateValue, java.util.Collection<java.lang.String> dateFormats, java.util.Date startDate) throws java.text.ParseException
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.java.text.ParseException
- if none of the dataFormats could parse the dateValuepublic static java.text.DateFormat getThreadLocalDateFormat()
DateFormat
for the current threadpublic static java.util.Calendar formatDate(java.util.Date date, java.util.Calendar cal, java.lang.Appendable out) throws java.io.IOException
java.io.IOException