类 DateUtils
- java.lang.Object
-
- com.baidubce.util.DateUtils
-
public class DateUtils extends Object
Utilities for parsing and formatting dates.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.
-
-
构造器概要
构造器 构造器 说明 DateUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static StringformatAlternateIso8601Date(Date date)Formats the specified date as an ISO 8601 string.static StringformatIso8601Date(Date date)Formats the specified date as an ISO 8601 string.static StringformatRfc822Date(Date date)Formats the specified date as an RFC 822 string.static DateparseAlternateIso8601Date(String dateString)Parses the specified date string as an ISO 8601 date and returns the Date object.static DateparseCompressedIso8601Date(String dateString)Parses the specified date string as a compressedIso8601DateFormat ("yyyyMMdd'T'HHmmss'Z'") and returns the Date object.static DateparseIso8601Date(String dateString)Parses the specified date string as an ISO 8601 date and returns the Date object.static DateparseRfc822Date(String dateString)Parses the specified date string as an RFC 822 date and returns the Date object.static voidvalidateUtcDate(String dateString)
-
-
-
方法详细资料
-
parseIso8601Date
public static Date parseIso8601Date(String dateString)
Parses the specified date string as an ISO 8601 date and returns the Date object.- 参数:
dateString- The date string to parse.- 返回:
- The parsed Date object.
- 抛出:
IllegalArgumentException- If the date string could not be parsed.
-
formatIso8601Date
public static String formatIso8601Date(Date date)
Formats the specified date as an ISO 8601 string.- 参数:
date- The date to format.- 返回:
- The ISO 8601 string representing the specified date.
-
parseAlternateIso8601Date
public static Date parseAlternateIso8601Date(String dateString)
Parses the specified date string as an ISO 8601 date and returns the Date object.- 参数:
dateString- The date string to parse.- 返回:
- The parsed Date object.
- 抛出:
IllegalArgumentException- If the date string could not be parsed.
-
formatAlternateIso8601Date
public static String formatAlternateIso8601Date(Date date)
Formats the specified date as an ISO 8601 string.- 参数:
date- The date to format.- 返回:
- The ISO 8601 string representing the specified date.
-
parseRfc822Date
public static Date parseRfc822Date(String dateString)
Parses the specified date string as an RFC 822 date and returns the Date object.- 参数:
dateString- The date string to parse.- 返回:
- The parsed Date object.
- 抛出:
IllegalArgumentException- If the date string could not be parsed.
-
formatRfc822Date
public static String formatRfc822Date(Date date)
Formats the specified date as an RFC 822 string.- 参数:
date- The date to format.- 返回:
- The RFC 822 string representing the specified date.
-
parseCompressedIso8601Date
public static Date parseCompressedIso8601Date(String dateString)
Parses the specified date string as a compressedIso8601DateFormat ("yyyyMMdd'T'HHmmss'Z'") and returns the Date object.- 参数:
dateString- The date string to parse.- 返回:
- The parsed Date object.
- 抛出:
IllegalArgumentException- If the date string could not be parsed.
-
validateUtcDate
public static void validateUtcDate(String dateString)
-
-