public class DateFormatUtil extends Object
| 构造器 | 说明 |
|---|---|
DateFormatUtil() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static String |
format(String skeleton,
String languageTag,
String timeZone,
long startTime,
long endTime) |
Obtains the text description of a datetime interval between two calendar times.
|
static String |
getBestPattern(String skeleton,
Locale locale) |
Obtains the most suitable format in the region specified by
java.util.Locale based on a given string representing the date and
time format. |
static String[] |
getLongStandAloneWeekdayNames(Locale locale) |
Obtains the full names of all standalone weekdays for the locale specified by
Locale. |
static char[] |
getOrder(String pattern) |
Obtains the sequence of the year, month, and day fields in a date pattern.
|
static String[] |
getShortMonthNames(Locale locale) |
Obtains the short names of all non-standalone months for the locale specified
by
Locale. |
static String[] |
getShortStandAloneMonthNames(Locale locale) |
Obtains the short names of all standalone months for the locale specified by
Locale. |
static String[] |
getShortStandAloneWeekdayNames(Locale locale) |
Obtains the short names of all standalone weekdays for the locale specified
by
Locale. |
static String |
getTimeFormat_hm(Locale locale) |
Obtains the 12-hour time format for the locale specified by
Locale. |
static String |
getTimeFormat_Hm(Locale locale) |
Obtains the 24-hour time format for the locale specified by
Locale. |
static boolean |
is24HourClock(Context context) |
Checks whether the system is using the 24-hour clock.
|
public static String getBestPattern(String skeleton, Locale locale)
java.util.Locale based on a given string representing the date and
time format.skeleton - Indicates the string representing the date and time format,
for example, MMDD.locale - Indicates the specified region based on which the date and
time will be formatted.public static char[] getOrder(String pattern)
pattern - Indicates the string representing the date format.char[] containing only three fields: Y for
year, M for month, and D for day. The fields are
displayed in the same sequence as in the date pattern.public static boolean is24HourClock(Context context)
If users have set the time format to the 24-hour clock, this method returns
true; otherwise, this method returns the result (either true
or false), depending on the conventions of the current locale.
context - Indicates the context to use.true if the 24-hour clock is used; returns
false otherwise.public static String[] getLongStandAloneWeekdayNames(Locale locale)
Locale.locale - indicates locale associate with data to be retrievedpublic static String[] getShortStandAloneWeekdayNames(Locale locale)
Locale.locale - indicates locale associate with data to be retrievedpublic static String[] getShortStandAloneMonthNames(Locale locale)
Locale.locale - indicates locale associate with data to be retrievedpublic static String[] getShortMonthNames(Locale locale)
Locale.locale - indicates locale associate with data to be retrievedpublic static String getTimeFormat_hm(Locale locale)
Locale.locale - indicates locale associate with data to be retrievedpublic static String getTimeFormat_Hm(Locale locale)
Locale.locale - indicates locale associate with data to be retrievedpublic static String format(String skeleton, String languageTag, String timeZone, long startTime, long endTime)
skeleton - indicates the pattern to format a datetime.languageTag - indicates locale of the pattern.timeZone - indicates the timezone info.startTime - start time of a interval(milliSeconds from January 1, 1970 00:00:00 UTC)endTime - end time of a interval(milliSeconds from January 1, 1970 00:00:00 UTC)