public class DateUtils extends Object
Note that this class doesn't use static methods because of the synchronization issues with SimpleDateFormat. This lets synchronization be done on a per-object level, instead of on a per-class level.
限定符和类型 | 字段和说明 |
---|---|
protected SimpleDateFormat |
alternateIso8601DateFormat
Alternate ISO 8601 format without fractional seconds
|
protected SimpleDateFormat |
compressedIso8601DateFormat
This is another ISO 8601 format that's used in clock skew error response
|
protected SimpleDateFormat |
iso8601DateFormat
ISO 8601 format
|
protected SimpleDateFormat |
rfc822DateFormat
RFC 822 format
|
protected SimpleDateFormat |
rfc822DateFormatUTC |
构造器和说明 |
---|
DateUtils()
Constructs a new DateUtils object, ready to parse/format dates.
|
限定符和类型 | 方法和说明 |
---|---|
String |
formatIso8601Date(Date date)
Formats the specified date as an ISO 8601 string.
|
String |
formatRfc822Date(Date date)
Formats the specified date as an RFC 822 string.
|
Date |
parseCompressedIso8601Date(String dateString)
Parses the specified date string as a compressedIso8601DateFormat ("yyyyMMdd'T'HHmmss'Z'") and returns the Date
object.
|
Date |
parseIso8601Date(String dateString)
Parses the specified date string as an ISO 8601 date and returns the Date
object.
|
Date |
parseRfc822Date(String dateString)
Parses the specified date string as an RFC 822 date and returns the Date
object.
|
protected final SimpleDateFormat iso8601DateFormat
protected final SimpleDateFormat alternateIso8601DateFormat
protected final SimpleDateFormat rfc822DateFormat
protected final SimpleDateFormat rfc822DateFormatUTC
protected final SimpleDateFormat compressedIso8601DateFormat
public DateUtils()
public Date parseIso8601Date(String dateString) throws ParseException
dateString
- The date string to parse.ParseException
- If the date string could not be parsed.public String formatIso8601Date(Date date)
date
- The date to format.public Date parseRfc822Date(String dateString) throws ParseException
dateString
- The date string to parse.ParseException
- If the date string could not be parsed.public String formatRfc822Date(Date date)
date
- The date to format.public Date parseCompressedIso8601Date(String dateString) throws ParseException
dateString
- The date string to parse.ParseException
- If the date string could not be parsed.Copyright © 2016. All rights reserved.