public final class DateUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
DateUtils.DateLocale
The locale interface for the output text for the formatting of dates.
|
Modifier and Type | Field and Description |
---|---|
static DateUtils.DateLocale |
DEFAULT_LOCALE
The default locale for names of parts of the calendar.
|
Constructor and Description |
---|
DateUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
formatTime(DateUtils.DateLocale locale,
long time,
java.lang.String formatString)
Formats a millisecond time into a formatted date string.
|
public static final DateUtils.DateLocale DEFAULT_LOCALE
public static java.lang.String formatTime(DateUtils.DateLocale locale, long time, java.lang.String formatString)
Uses repeated patterns of the following letters to output parts of a number that represents a point in time. The formatting string can output quoted characters as-is if those series of characters are enclosed in single-quotes ('). Unrecognized characters are output as-is.
"Text" types print full names at 4 or more of the same letter (or may max out at less letters), "number" types print a minimum of the amount of digits represented by the amount of letters, padding the rest of the digits with zeroes, "month" types print numbers at 2 or less letters, text at 3 or more.
Letter | Part of Date | Type | Examples |
---|---|---|---|
e | Era Designator (lowercase) | Text | a; ad |
E | Era Designator (uppercase) | Text | A; AD |
y | Year | Number | 09; 2009 |
M | Month in Year | Month | 09; Sep; September |
d | Day in Month | Number | 5; 05 |
W | Day of Week in Month (Name) | Text | T; Tu; Tue; Tuesday |
w | Day Number of Week (0=Sunday, ... , 6=Saturday) | Number | 2 |
a | am/pm marker (lower case) | Text | a; am |
A | AM/PM marker (upper case) | Text | A; AM |
h | Hour in Day (0-23) | Number | 8; 08 |
H | Hour in Day (1-24) | Number | 9; 09 |
k | Hour in Day (AM/PM) (0-11) | Number | 8; 08 |
K | Hour in Day (AM/PM) (1-12) | Number | 9; 09 |
m | Minute in Hour | Number | 3; 03 |
s | Seconds in Minute | Number | 3; 03 |
S | Milliseconds in Second | Number | 567 |
z | Time Zone | Text | GMT-08:00 |
Z | RFC 822 Time Zone | Text | -0800 |
X | Variable Length Time Zone | Text | -8; -08; -0800; -08:00; GMT-08:00 |
locale
- the locale type to use for the names of days and months.time
- the input time in milliseconds since the epoch.formatString
- the formatting string.