Package software.amazon.awssdk.utils
Class DateUtils
- java.lang.Object
-
- software.amazon.awssdk.utils.DateUtils
-
@ThreadSafe public final class DateUtils extends Object
Utilities for parsing and formatting dates.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
formatIso8601Date(Instant date)
Formats the specified date as an ISO 8601 string.static String
formatRfc1123Date(Instant instant)
Formats the specified date as an RFC 1123 string.static String
formatRfc822Date(Instant instant)
Formats the specified date as an RFC 822 string.static String
formatUnixTimestampInstant(Instant instant)
Formats the giveInstant
object into an Unix timestamp with millisecond decimal precision.static long
numberOfDaysSinceEpoch(long milliSinceEpoch)
Returns the number of days since epoch with respect to the given number of milliseconds since epoch.static Instant
parseIso8601Date(String dateString)
Parses the specified date string as an ISO 8601 date (yyyy-MM-dd'T'HH:mm:ss.SSSZZ) and returns theInstant
object.static Instant
parseRfc1123Date(String dateString)
Parses the specified date string as an RFC 1123 date and returns the Date object.static Instant
parseRfc822Date(String dateString)
Parses the specified date string as an RFC 822 date and returns the Date object.static Instant
parseUnixTimestampInstant(String dateString)
Parses the given string containing a Unix timestamp with millisecond decimal precision into anInstant
object.static Instant
parseUnixTimestampMillisInstant(String dateString)
Parses the given string containing a Unix timestamp in epoch millis into aInstant
object.
-
-
-
Method Detail
-
parseIso8601Date
public static Instant parseIso8601Date(String dateString)
Parses the specified date string as an ISO 8601 date (yyyy-MM-dd'T'HH:mm:ss.SSSZZ) and returns theInstant
object.- Parameters:
dateString
- The date string to parse.- Returns:
- The parsed Instant object.
-
formatIso8601Date
public static String formatIso8601Date(Instant date)
Formats the specified date as an ISO 8601 string.- Parameters:
date
- the date to format- Returns:
- the ISO-8601 string representing the specified date
-
parseRfc822Date
public static Instant parseRfc822Date(String dateString)
Parses the specified date string as an RFC 822 date and returns the Date object.- Parameters:
dateString
- The date string to parse.- Returns:
- The parsed Date object.
-
formatRfc822Date
public static String formatRfc822Date(Instant instant)
Formats the specified date as an RFC 822 string.- Parameters:
instant
- The instant to format.- Returns:
- The RFC 822 string representing the specified date.
-
parseRfc1123Date
public static Instant parseRfc1123Date(String dateString)
Parses the specified date string as an RFC 1123 date and returns the Date object.- Parameters:
dateString
- The date string to parse.- Returns:
- The parsed Date object.
-
formatRfc1123Date
public static String formatRfc1123Date(Instant instant)
Formats the specified date as an RFC 1123 string.- Parameters:
instant
- The instant to format.- Returns:
- The RFC 1123 string representing the specified date.
-
numberOfDaysSinceEpoch
public static long numberOfDaysSinceEpoch(long milliSinceEpoch)
Returns the number of days since epoch with respect to the given number of milliseconds since epoch.
-
parseUnixTimestampInstant
public static Instant parseUnixTimestampInstant(String dateString) throws NumberFormatException
Parses the given string containing a Unix timestamp with millisecond decimal precision into anInstant
object.- Throws:
NumberFormatException
-
parseUnixTimestampMillisInstant
public static Instant parseUnixTimestampMillisInstant(String dateString) throws NumberFormatException
Parses the given string containing a Unix timestamp in epoch millis into aInstant
object.- Throws:
NumberFormatException
-
-