public class FastDateFormat extends java.text.Format implements DateParser, DatePrinter
FastDateFormat 是一个线程安全的 SimpleDateFormat 实现。
通过以下静态方法获得此对象:
getInstance(String, TimeZone, Locale)
getDateInstance(int, TimeZone, Locale)
getTimeInstance(int, TimeZone, Locale)
getDateTimeInstance(int, int, TimeZone, Locale)
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
FULL
FULL locale dependent date or time style.
|
static int |
LONG
LONG locale dependent date or time style.
|
static int |
MEDIUM
MEDIUM locale dependent date or time style.
|
static int |
SHORT
SHORT locale dependent date or time style.
|
| 限定符 | 构造器和说明 |
|---|---|
protected |
FastDateFormat(java.lang.String pattern,
java.util.TimeZone timeZone,
java.util.Locale locale)
构造
|
protected |
FastDateFormat(java.lang.String pattern,
java.util.TimeZone timeZone,
java.util.Locale locale,
java.util.Date centuryStart)
构造
|
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
equals(java.lang.Object obj) |
java.lang.String |
format(java.util.Calendar calendar)
Formats a
Calendar object. |
<B extends java.lang.Appendable> |
format(java.util.Calendar calendar,
B buf)
Formats a
Calendar object into the supplied Appendable. |
java.lang.String |
format(java.util.Date date)
使用
GregorianCalendar 格式化 Date |
<B extends java.lang.Appendable> |
format(java.util.Date date,
B buf)
Formats a
Date object into the supplied Appendable using a GregorianCalendar. |
java.lang.String |
format(long millis)
格式化日期表示的毫秒数
|
<B extends java.lang.Appendable> |
format(long millis,
B buf)
Formats a millisecond
long value into the supplied Appendable. |
java.lang.StringBuffer |
format(java.lang.Object obj,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos) |
static FastDateFormat |
getDateInstance(int style)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getDateInstance(int style,
java.util.Locale locale)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getDateInstance(int style,
java.util.TimeZone timeZone)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getDateInstance(int style,
java.util.TimeZone timeZone,
java.util.Locale locale)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle,
java.util.Locale locale)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle,
java.util.TimeZone timeZone)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getDateTimeInstance(int dateStyle,
int timeStyle,
java.util.TimeZone timeZone,
java.util.Locale locale)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getInstance()
获得
FastDateFormat 实例,使用默认格式和地区 |
static FastDateFormat |
getInstance(java.lang.String pattern)
获得
FastDateFormat 实例,使用默认地区支持缓存 |
static FastDateFormat |
getInstance(java.lang.String pattern,
java.util.Locale locale)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getInstance(java.lang.String pattern,
java.util.TimeZone timeZone)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getInstance(java.lang.String pattern,
java.util.TimeZone timeZone,
java.util.Locale locale)
获得
FastDateFormat 实例支持缓存 |
java.util.Locale |
getLocale()
获得 日期地理位置
|
int |
getMaxLengthEstimate()
估算生成的日期字符串长度
实际生成的字符串长度小于或等于此值 |
java.lang.String |
getPattern()
获得日期格式化或者转换的格式
|
static FastDateFormat |
getTimeInstance(int style)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getTimeInstance(int style,
java.util.Locale locale)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getTimeInstance(int style,
java.util.TimeZone timeZone)
获得
FastDateFormat 实例支持缓存 |
static FastDateFormat |
getTimeInstance(int style,
java.util.TimeZone timeZone,
java.util.Locale locale)
获得
FastDateFormat 实例支持缓存 |
java.util.TimeZone |
getTimeZone()
获得时区
|
int |
hashCode() |
java.util.Date |
parse(java.lang.String source)
将日期字符串解析并转换为
Date 对象等价于 DateFormat.parse(String) |
java.util.Date |
parse(java.lang.String source,
java.text.ParsePosition pos)
将日期字符串解析并转换为
Date 对象等价于 DateFormat.parse(String, ParsePosition) |
boolean |
parse(java.lang.String source,
java.text.ParsePosition pos,
java.util.Calendar calendar)
根据给定格式转换日期字符串
Updates the Calendar with parsed fields.
|
java.lang.Object |
parseObject(java.lang.String source,
java.text.ParsePosition pos)
根据
ParsePosition 给定将日期字符串解析并转换为 Date 对象 |
java.lang.String |
toString() |
parseObjectpublic static final int FULL
public static final int LONG
public static final int MEDIUM
public static final int SHORT
protected FastDateFormat(java.lang.String pattern,
java.util.TimeZone timeZone,
java.util.Locale locale)
pattern - 使用SimpleDateFormat 相同的日期格式timeZone - 非空时区 TimeZonelocale - Locale 日期地理位置java.lang.NullPointerException - if pattern, timeZone, or locale is null.protected FastDateFormat(java.lang.String pattern,
java.util.TimeZone timeZone,
java.util.Locale locale,
java.util.Date centuryStart)
pattern - 使用SimpleDateFormat 相同的日期格式timeZone - 非空时区 TimeZonelocale - Locale 日期地理位置centuryStart - The start of the 100 year period to use as the "default century" for 2 digit year parsing. If centuryStart is null, defaults to now - 80 yearsjava.lang.NullPointerException - if pattern, timeZone, or locale is null.public static FastDateFormat getInstance()
FastDateFormat 实例,使用默认格式和地区public static FastDateFormat getInstance(java.lang.String pattern)
FastDateFormat 实例,使用默认地区pattern - 使用SimpleDateFormat 相同的日期格式FastDateFormatjava.lang.IllegalArgumentException - 日期格式问题public static FastDateFormat getInstance(java.lang.String pattern, java.util.TimeZone timeZone)
FastDateFormat 实例pattern - 使用SimpleDateFormat 相同的日期格式timeZone - 时区TimeZoneFastDateFormatjava.lang.IllegalArgumentException - 日期格式问题public static FastDateFormat getInstance(java.lang.String pattern, java.util.Locale locale)
FastDateFormat 实例pattern - 使用SimpleDateFormat 相同的日期格式locale - Locale 日期地理位置FastDateFormatjava.lang.IllegalArgumentException - 日期格式问题public static FastDateFormat getInstance(java.lang.String pattern, java.util.TimeZone timeZone, java.util.Locale locale)
FastDateFormat 实例pattern - 使用SimpleDateFormat 相同的日期格式timeZone - 时区TimeZonelocale - Locale 日期地理位置FastDateFormatjava.lang.IllegalArgumentException - 日期格式问题public static FastDateFormat getDateInstance(int style)
FastDateFormat 实例style - date style: FULL, LONG, MEDIUM, or SHORTFastDateFormatpublic static FastDateFormat getDateInstance(int style, java.util.Locale locale)
FastDateFormat 实例style - date style: FULL, LONG, MEDIUM, or SHORTlocale - Locale 日期地理位置FastDateFormatpublic static FastDateFormat getDateInstance(int style, java.util.TimeZone timeZone)
FastDateFormat 实例style - date style: FULL, LONG, MEDIUM, or SHORTtimeZone - 时区TimeZoneFastDateFormatpublic static FastDateFormat getDateInstance(int style, java.util.TimeZone timeZone, java.util.Locale locale)
FastDateFormat 实例style - date style: FULL, LONG, MEDIUM, or SHORTtimeZone - 时区TimeZonelocale - Locale 日期地理位置FastDateFormatpublic static FastDateFormat getTimeInstance(int style)
FastDateFormat 实例style - time style: FULL, LONG, MEDIUM, or SHORTFastDateFormatpublic static FastDateFormat getTimeInstance(int style, java.util.Locale locale)
FastDateFormat 实例style - time style: FULL, LONG, MEDIUM, or SHORTlocale - Locale 日期地理位置FastDateFormatpublic static FastDateFormat getTimeInstance(int style, java.util.TimeZone timeZone)
FastDateFormat 实例style - time style: FULL, LONG, MEDIUM, or SHORTtimeZone - optional time zone, overrides time zone of formatted timeFastDateFormatpublic static FastDateFormat getTimeInstance(int style, java.util.TimeZone timeZone, java.util.Locale locale)
FastDateFormat 实例style - time style: FULL, LONG, MEDIUM, or SHORTtimeZone - optional time zone, overrides time zone of formatted timelocale - Locale 日期地理位置FastDateFormatpublic static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle)
FastDateFormat 实例dateStyle - date style: FULL, LONG, MEDIUM, or SHORTtimeStyle - time style: FULL, LONG, MEDIUM, or SHORTFastDateFormatpublic static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, java.util.Locale locale)
FastDateFormat 实例dateStyle - date style: FULL, LONG, MEDIUM, or SHORTtimeStyle - time style: FULL, LONG, MEDIUM, or SHORTlocale - Locale 日期地理位置FastDateFormatpublic static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, java.util.TimeZone timeZone)
FastDateFormat 实例dateStyle - date style: FULL, LONG, MEDIUM, or SHORTtimeStyle - time style: FULL, LONG, MEDIUM, or SHORTtimeZone - 时区TimeZoneFastDateFormatpublic static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, java.util.TimeZone timeZone, java.util.Locale locale)
FastDateFormat 实例dateStyle - date style: FULL, LONG, MEDIUM, or SHORTtimeStyle - time style: FULL, LONG, MEDIUM, or SHORTtimeZone - 时区TimeZonelocale - Locale 日期地理位置FastDateFormatpublic java.lang.StringBuffer format(java.lang.Object obj,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos)
format 在类中 java.text.Formatpublic java.lang.String format(long millis)
DatePrinterformat 在接口中 DatePrintermillis - 日期毫秒数public java.lang.String format(java.util.Date date)
DatePrinterGregorianCalendar 格式化 Dateformat 在接口中 DatePrinterdate - 日期 Datepublic java.lang.String format(java.util.Calendar calendar)
DatePrinter
Formats a Calendar object.
Calendarformat 在接口中 DatePrintercalendar - Calendarpublic <B extends java.lang.Appendable> B format(long millis,
B buf)
DatePrinter
Formats a millisecond long value into the supplied Appendable.
format 在接口中 DatePrinterB - the Appendable class type, usually StringBuilder or StringBuffer.millis - the millisecond value to formatbuf - the buffer to format intopublic <B extends java.lang.Appendable> B format(java.util.Date date,
B buf)
DatePrinter
Formats a Date object into the supplied Appendable using a GregorianCalendar.
format 在接口中 DatePrinterB - the Appendable class type, usually StringBuilder or StringBuffer.date - the date to formatbuf - the buffer to format intopublic <B extends java.lang.Appendable> B format(java.util.Calendar calendar,
B buf)
DatePrinter
Formats a Calendar object into the supplied Appendable.
format 在接口中 DatePrinterB - the Appendable class type, usually StringBuilder or StringBuffer.calendar - the calendar to formatbuf - the buffer to format intopublic java.util.Date parse(java.lang.String source)
throws java.text.ParseException
DateParserDate 对象DateFormat.parse(String)parse 在接口中 DateParsersource - 日期字符串Datejava.text.ParseException - 转换异常,被转换的字符串格式错误。public java.util.Date parse(java.lang.String source,
java.text.ParsePosition pos)
DateParserDate 对象DateFormat.parse(String, ParsePosition)parse 在接口中 DateParsersource - 日期字符串pos - ParsePositionDatepublic boolean parse(java.lang.String source,
java.text.ParsePosition pos,
java.util.Calendar calendar)
DateParserparse 在接口中 DateParsersource - 被转换的日期字符串pos - 定义开始转换的位置,转换结束后更新转换到的位置calendar - The calendar into which to set parsed fields.public java.lang.Object parseObject(java.lang.String source,
java.text.ParsePosition pos)
DateParserParsePosition 给定将日期字符串解析并转换为 Date 对象parseObject 在接口中 DateParserparseObject 在类中 java.text.Formatsource - A String whose beginning should be parsed.pos - the parse positionjava.util.Date objectDateFormat.parseObject(String, ParsePosition)public java.lang.String getPattern()
DateBasicgetPattern 在接口中 DateBasicSimpleDateFormat兼容的格式public java.util.TimeZone getTimeZone()
DateBasicgetTimeZone 在接口中 DateBasicTimeZonepublic java.util.Locale getLocale()
DateBasicpublic int getMaxLengthEstimate()
public boolean equals(java.lang.Object obj)
equals 在类中 java.lang.Objectpublic int hashCode()
hashCode 在类中 java.lang.Objectpublic java.lang.String toString()
toString 在类中 java.lang.ObjectCopyright © 2018. All rights reserved.