Package oracle.i18n.text
Class OraDateFormat
- java.lang.Object
-
- java.text.Format
-
- oracle.i18n.text.OraDateFormat
-
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
OraSimpleDateFormat
public abstract class OraDateFormat extends Format
TheOraDateFormatclass is an abstract class to do locale-sensitive formatting and parsing between date/time and string. It supports Oracle date/time formatting behavior.- See Also:
OraSimpleDateFormat, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.text.Format
Format.Field
-
-
Field Summary
Fields Modifier and Type Field Description static intALL_FIELDConstant forALL_FIELDalignment.static intAM_PM_FIELDConstant forAM_PM_FIELDalignment.protected CalendarcalendarThe calendar that thisOraDateFormatobject uses to calculate the date/time field values.static intCENTRY_FIELDConstant forCENTRY_FIELDalignment.static intDATE_FIELDConstant forDATE_FIELDalignment.static intDAY_OF_WEEK_FIELDConstant forDAY_OF_WEEK_FIELDalignment.static intDAY_OF_YEAR_FIELDConstant forDAY_OF_YEAR_FIELDalignment.static intDEFAULTConstant forDEFAULTformat style.static intERA_FIELDConstant forERA_FIELDalignment.static intHOUR_FIELDConstant forHOUR_FIELDalignment.static intHOUR_OF_DAY_FIELDConstant forHOUR_OF_DAY_FIELDalignment.static intISO_WEEK_OF_YEAR_FIELDConstant forISO_WEEK_OF_YEAR_FIELDalignment.static intISO_YEAR_FIELDConstant forISO_YEAR_FIELDalignment.static intJULIAN_DAY_FIELDConstant forJULIAN_DAY_FIELDalignment.static intLONGConstant for dateLONGformat style.static intMILLISECOND_FIELDConstant forMILLISECOND_FIELDalignment.static intMINUTE_FIELDConstant forMINUTE_FIELDalignment.static intMONTH_FIELDConstant forMONTH_FIELDalignment.static intQUARTER_OF_YEAR_FIELDConstant forQUARTER_OF_YEAR_FIELDalignment.static intSECOND_FIELDConstant forSECOND_FIELDalignment.static intSECONDS_FIELDConstant forSECONDS_FIELDalignment.static intSHORTConstant for date/timeSHORTformat style.static intTEXT_FIELDConstant forTEXT_FIELDalignment.static intTIMEZONE_FIELDConstant forTIMEZONE_FIELDalignment.static intWEEK_OF_MONTH_FIELDConstant forWEEK_OF_MONTH_FIELDalignment.static intWEEK_OF_YEAR_FIELDConstant forWEEK_OF_YEAR_FIELDalignment.static intYEAR_FIELDConstant forYEAR_FIELDalignment.
-
Constructor Summary
Constructors Constructor Description OraDateFormat()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Objectclone()Overrides theclonemethod.booleanequals(Object obj)Overrides theequalsmethod.StringBufferformat(Object obj, StringBuffer toAppendTo, FieldPosition fieldPosition)Formats an object into a date/time string.Stringformat(Date date)Formats aDateobject into a date/time string.abstract StringBufferformat(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)Formats aDateobject into a date/time string.CalendargetCalendar()Returns the calendar associated with this date/time formatter.static OraDateFormatgetDateInstance()Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateInstance(int, Locale)static OraDateFormatgetDateInstance(int style)Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateInstance(int, Locale)static OraDateFormatgetDateInstance(int style, Locale locale)Returns a date formatter that uses the given date formatting style for the given locale.static OraDateFormatgetDateInstance(int style, OraLocaleInfo localeInfo)Returns a date formatter that uses the given date formatting style for the givenOraLocaleInfoobject.static OraDateFormatgetDateTimeInstance()Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateTimeInstance(int, Locale)static OraDateFormatgetDateTimeInstance(int dateStyle)Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateTimeInstance(int, Locale)static OraDateFormatgetDateTimeInstance(int dateStyle, Locale locale)Returns a date/time formatter that uses the given date formatting style and the default time formatting style for the given locale.static OraDateFormatgetDateTimeInstance(int dateStyle, OraLocaleInfo localeInfo)Returns a date/time formatter that uses the given date formatting style and the default time formatting style for the givenOraLocaleInfoobject.static StringgetDefaultDateFormatPattern(int style, Locale locale)Returns the default date format pattern for the given date formatting style and the given locale.static StringgetDefaultDateFormatPattern(int style, OraLocaleInfo localeInfo)Returns the default date format pattern for the given date formatting style and the givenOraLocaleInfoobject.static StringgetDefaultDateTimeFormatPattern(int dateStyle, Locale locale)Returns the default date/time format pattern for the given date formatting style and the given locale.static StringgetDefaultDateTimeFormatPattern(int dateStyle, OraLocaleInfo localeInfo)Returns the default date/time format pattern for the given date formatting style and the givenOraLocaleInfoobject.static StringgetDefaultTimeFormatPattern(Locale locale)Returns the default time format pattern for the given locale.static StringgetDefaultTimeFormatPattern(OraLocaleInfo localeInfo)Returns the default time format pattern for the givenOraLocaleInfoobject.static OraDateFormatgetInstance()Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateTimeInstance(int, Locale)static OraDateFormatgetTimeInstance()Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetTimeInstance(Locale)static OraDateFormatgetTimeInstance(Locale locale)Returns a time formatter for the given locale.static OraDateFormatgetTimeInstance(OraLocaleInfo localeInfo)Returns a time formatter for the givenOraLocaleInfoobject.TimeZonegetTimeZone()Returns the time zone associated with the calendar of this formatter.Dateparse(String text)Parses a date/time string into a date.abstract Dateparse(String text, ParsePosition pos)Parses a date/time string into a date, starting from the given parse position.ObjectparseObject(String text, ParsePosition pos)Parses a date/time string into a (Date) object, starting from the given parse position.voidsetCalendar(Calendar calendar)Sets the given calendar to be used by this date/time formatter.voidsetTimeZone(TimeZone timezone)Sets the given time zone to be used by the calendar of this formatter.-
Methods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject
-
-
-
-
Field Detail
-
ERA_FIELD
public static final int ERA_FIELD
Constant forERA_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
YEAR_FIELD
public static final int YEAR_FIELD
Constant forYEAR_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
MONTH_FIELD
public static final int MONTH_FIELD
Constant forMONTH_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
DATE_FIELD
public static final int DATE_FIELD
Constant forDATE_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
HOUR_OF_DAY_FIELD
public static final int HOUR_OF_DAY_FIELD
Constant forHOUR_OF_DAY_FIELDalignment. Used to specify the field position for formatting. TheHOUR_OF_DAY_FIELDis used for zero-base, 24-hour clock (0 ~ 23).- See Also:
- Constant Field Values
-
MINUTE_FIELD
public static final int MINUTE_FIELD
Constant forMINUTE_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
SECOND_FIELD
public static final int SECOND_FIELD
Constant forSECOND_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
MILLISECOND_FIELD
public static final int MILLISECOND_FIELD
Constant forMILLISECOND_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
DAY_OF_WEEK_FIELD
public static final int DAY_OF_WEEK_FIELD
Constant forDAY_OF_WEEK_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
DAY_OF_YEAR_FIELD
public static final int DAY_OF_YEAR_FIELD
Constant forDAY_OF_YEAR_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
WEEK_OF_YEAR_FIELD
public static final int WEEK_OF_YEAR_FIELD
Constant forWEEK_OF_YEAR_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
WEEK_OF_MONTH_FIELD
public static final int WEEK_OF_MONTH_FIELD
Constant forWEEK_OF_MONTH_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
AM_PM_FIELD
public static final int AM_PM_FIELD
Constant forAM_PM_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
HOUR_FIELD
public static final int HOUR_FIELD
Constant forHOUR_FIELDalignment. Used to specify the field position for formatting. TheHOUR_FIELDis used for one-base, 12-hour clock (1 ~ 12).- See Also:
- Constant Field Values
-
TIMEZONE_FIELD
public static final int TIMEZONE_FIELD
Constant forTIMEZONE_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
ALL_FIELD
public static final int ALL_FIELD
Constant forALL_FIELDalignment. Used to specify the field position for formatting. TheALL_FIELDis used to indicate all fields specified in a format pattern.- See Also:
- Constant Field Values
-
CENTRY_FIELD
public static final int CENTRY_FIELD
Constant forCENTRY_FIELDalignment. Used to specify the field position for formatting. Centry is one greater than the first two digits of a four-digit year.- See Also:
- Constant Field Values
-
JULIAN_DAY_FIELD
public static final int JULIAN_DAY_FIELD
Constant forJULIAN_DAY_FIELDalignment. Used to specify the field position for formatting. The Julian day is number of days since January 1, 4712 BC.- See Also:
- Constant Field Values
-
QUARTER_OF_YEAR_FIELD
public static final int QUARTER_OF_YEAR_FIELD
Constant forQUARTER_OF_YEAR_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
SECONDS_FIELD
public static final int SECONDS_FIELD
Constant forSECONDS_FIELDalignment. Used to specify the field position for formatting. TheSECONDS_FIELDis for number of seconds past midnight.- See Also:
- Constant Field Values
-
TEXT_FIELD
public static final int TEXT_FIELD
Constant forTEXT_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
ISO_YEAR_FIELD
public static final int ISO_YEAR_FIELD
Constant forISO_YEAR_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
ISO_WEEK_OF_YEAR_FIELD
public static final int ISO_WEEK_OF_YEAR_FIELD
Constant forISO_WEEK_OF_YEAR_FIELDalignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
SHORT
public static final int SHORT
Constant for date/timeSHORTformat style.- See Also:
- Constant Field Values
-
LONG
public static final int LONG
Constant for dateLONGformat style.- See Also:
- Constant Field Values
-
DEFAULT
public static final int DEFAULT
Constant forDEFAULTformat style. For date, it is equivalent to Oracle server default date format. For time, it is equivalent to the timeSHORTformat style.- See Also:
- Constant Field Values
-
calendar
protected Calendar calendar
The calendar that thisOraDateFormatobject uses to calculate the date/time field values. Subclasses should initialize thecalendarobject accordingly based on the locale associated with thisOraDateFormatobject.
-
-
Method Detail
-
getDateInstance
public static final OraDateFormat getDateInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateInstance(int, Locale)Returns a date formatter that uses the default date formatting style for the default locale.- Returns:
- a date formatter
-
getDateInstance
public static final OraDateFormat getDateInstance(int style)
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateInstance(int, Locale)Returns a date formatter that uses the given date formatting style for the default locale.- Parameters:
style- the given date formatting style; options areSHORT,LONGorDEFAULT- Returns:
- a date formatter
-
getDateInstance
public static final OraDateFormat getDateInstance(int style, Locale locale)
Returns a date formatter that uses the given date formatting style for the given locale.- Parameters:
style- the given date formatting style; options areSHORT,LONGorDEFAULTlocale- the given locale- Returns:
- a date formatter
-
getDateInstance
public static final OraDateFormat getDateInstance(int style, OraLocaleInfo localeInfo)
Returns a date formatter that uses the given date formatting style for the givenOraLocaleInfoobject.- Parameters:
style- the given date formatting style; options areSHORT,LONGorDEFAULTlocaleInfo- the givenOraLocaleInfoobject- Returns:
- a date formatter
- Throws:
IllegalArgumentException- if the given date formatting style is invalid
-
getDateTimeInstance
public static final OraDateFormat getDateTimeInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateTimeInstance(int, Locale)Returns a date/time formatter that uses the default date/time formatting style for the default locale.- Returns:
- a date/time formatter
-
getDateTimeInstance
public static final OraDateFormat getDateTimeInstance(int dateStyle)
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateTimeInstance(int, Locale)Returns a date/time formatter that uses the given date formatting style and the default time formatting style for the default locale.- Parameters:
dateStyle- the given date formatting style; options areSHORT,LONGorDEFAULT- Returns:
- a date/time formatter
-
getDateTimeInstance
public static final OraDateFormat getDateTimeInstance(int dateStyle, Locale locale)
Returns a date/time formatter that uses the given date formatting style and the default time formatting style for the given locale.- Parameters:
dateStyle- the given date formatting style; options areSHORT,LONGorDEFAULTlocale- the given locale- Returns:
- a date/time formatter
-
getDateTimeInstance
public static final OraDateFormat getDateTimeInstance(int dateStyle, OraLocaleInfo localeInfo)
Returns a date/time formatter that uses the given date formatting style and the default time formatting style for the givenOraLocaleInfoobject.- Parameters:
dateStyle- the given date formatting style; options areSHORT,LONGorDEFAULTlocaleInfo- the givenOraLocaleInfoobject- Returns:
- a date/time formatter
- Throws:
IllegalArgumentException- if the given date formatting style is invalid
-
getInstance
public static final OraDateFormat getInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateTimeInstance(int, Locale)Returns a date/time formatter that uses the default date/time formatting style for the default locale.- Returns:
- a date/time formatter
-
getTimeInstance
public static final OraDateFormat getTimeInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetTimeInstance(Locale)Returns a time formatter that uses the default time formatting style for the default locale.- Returns:
- a time formatter
-
getTimeInstance
public static final OraDateFormat getTimeInstance(Locale locale)
Returns a time formatter for the given locale.- Parameters:
locale- the given locale- Returns:
- a time formatter
-
getTimeInstance
public static final OraDateFormat getTimeInstance(OraLocaleInfo localeInfo)
Returns a time formatter for the givenOraLocaleInfoobject.- Parameters:
localeInfo- the givenOraLocaleInfoobject- Returns:
- a time formatter
-
format
public final String format(Date date)
Formats aDateobject into a date/time string.- Parameters:
date- the date/time object to be formatted into a date/time string- Returns:
- the formatted date/time string
-
format
public abstract StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats aDateobject into a date/time string. Sets field position if it is needed.- Parameters:
date- the date/time object to be formatted into a date/time string.toAppendTo- the string buffer to be appended with the formatted date/time string.fieldPosition- to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.- Returns:
- the string buffer appended with the formatted date/time string
-
format
public final StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats an object into a date/time string. Sets field position if it is needed.- Specified by:
formatin classFormat- Parameters:
obj- the object to be formatted into a date/time string. It must be an instance ofDateorNumberclass.toAppendTo- the string buffer to be appended with the formatted date/time string.fieldPosition- to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.- Returns:
- the string buffer appended with the formatted date/time string
- Throws:
IllegalArgumentException- if the given object is neither an instance ofDateclass nor an instance ofNumberclass
-
parse
public Date parse(String text) throws ParseException
Parses a date/time string into a date.- Parameters:
text- the date/time string to be parsed- Returns:
- a
Dateobject corresponding to the date/time string - Throws:
ParseException- if the format pattern associated with this formatter is not valid for parsing or the given date/time string cannot be parsed into aDateobject
-
parse
public abstract Date parse(String text, ParsePosition pos)
Parses a date/time string into a date, starting from the given parse position.- Parameters:
text- the date/time string.pos- indicates where to start the parsing on input. On output, returns where the parse ends if parsing succeeds, or the start index if it fails.- Returns:
- a
Dateobject
-
parseObject
public Object parseObject(String text, ParsePosition pos)
Parses a date/time string into a (Date) object, starting from the given parse position. It is a convenient method which simply calls theparse(String, ParsePostion)method.- Specified by:
parseObjectin classFormat- See Also:
parse(String, ParsePosition)
-
getDefaultDateFormatPattern
public static String getDefaultDateFormatPattern(int style, Locale locale)
Returns the default date format pattern for the given date formatting style and the given locale.- Parameters:
style- the given date formatting stylelocale- the given locale- Returns:
- the default date format pattern
-
getDefaultDateFormatPattern
public static String getDefaultDateFormatPattern(int style, OraLocaleInfo localeInfo)
Returns the default date format pattern for the given date formatting style and the givenOraLocaleInfoobject.- Parameters:
style- the given date formatting stylelocaleInfo- the givenOraLocaleInfoobject- Returns:
- the default date format pattern
-
getDefaultDateTimeFormatPattern
public static String getDefaultDateTimeFormatPattern(int dateStyle, Locale locale)
Returns the default date/time format pattern for the given date formatting style and the given locale.- Parameters:
dateStyle- the given date formatting stylelocale- the given locale- Returns:
- the default date/time format pattern
-
getDefaultDateTimeFormatPattern
public static String getDefaultDateTimeFormatPattern(int dateStyle, OraLocaleInfo localeInfo)
Returns the default date/time format pattern for the given date formatting style and the givenOraLocaleInfoobject.- Parameters:
dateStyle- the given date formatting stylelocaleInfo- the givenOraLocaleInfoobject- Returns:
- the default date/time format pattern
-
getDefaultTimeFormatPattern
public static String getDefaultTimeFormatPattern(Locale locale)
Returns the default time format pattern for the given locale.- Parameters:
locale- the given locale- Returns:
- the default time format pattern
-
getDefaultTimeFormatPattern
public static String getDefaultTimeFormatPattern(OraLocaleInfo localeInfo)
Returns the default time format pattern for the givenOraLocaleInfoobject.- Parameters:
localeInfo- the givenOraLocaleInfoobject- Returns:
- the default time format pattern
-
getCalendar
public Calendar getCalendar()
Returns the calendar associated with this date/time formatter.- Returns:
- the
Calendarobject associated with this formatter
-
setCalendar
public void setCalendar(Calendar calendar)
Sets the given calendar to be used by this date/time formatter.- Parameters:
calendar- the givenCalendarobject to be used by this formatter
-
getTimeZone
public TimeZone getTimeZone()
Returns the time zone associated with the calendar of this formatter.- Returns:
- the
TimeZoneobject associated with the calendar of this formatter
-
setTimeZone
public void setTimeZone(TimeZone timezone)
Sets the given time zone to be used by the calendar of this formatter.- Parameters:
timezone- the givenTimeZoneobject to be used by the calendar of this formatter
-
clone
public Object clone()
Overrides theclonemethod.
-
-