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
TheOraDateFormat
class 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 int
ALL_FIELD
Constant forALL_FIELD
alignment.static int
AM_PM_FIELD
Constant forAM_PM_FIELD
alignment.protected Calendar
calendar
The calendar that thisOraDateFormat
object uses to calculate the date/time field values.static int
CENTRY_FIELD
Constant forCENTRY_FIELD
alignment.static int
DATE_FIELD
Constant forDATE_FIELD
alignment.static int
DAY_OF_WEEK_FIELD
Constant forDAY_OF_WEEK_FIELD
alignment.static int
DAY_OF_YEAR_FIELD
Constant forDAY_OF_YEAR_FIELD
alignment.static int
DEFAULT
Constant forDEFAULT
format style.static int
ERA_FIELD
Constant forERA_FIELD
alignment.static int
HOUR_FIELD
Constant forHOUR_FIELD
alignment.static int
HOUR_OF_DAY_FIELD
Constant forHOUR_OF_DAY_FIELD
alignment.static int
ISO_WEEK_OF_YEAR_FIELD
Constant forISO_WEEK_OF_YEAR_FIELD
alignment.static int
ISO_YEAR_FIELD
Constant forISO_YEAR_FIELD
alignment.static int
JULIAN_DAY_FIELD
Constant forJULIAN_DAY_FIELD
alignment.static int
LONG
Constant for dateLONG
format style.static int
MILLISECOND_FIELD
Constant forMILLISECOND_FIELD
alignment.static int
MINUTE_FIELD
Constant forMINUTE_FIELD
alignment.static int
MONTH_FIELD
Constant forMONTH_FIELD
alignment.static int
QUARTER_OF_YEAR_FIELD
Constant forQUARTER_OF_YEAR_FIELD
alignment.static int
SECOND_FIELD
Constant forSECOND_FIELD
alignment.static int
SECONDS_FIELD
Constant forSECONDS_FIELD
alignment.static int
SHORT
Constant for date/timeSHORT
format style.static int
TEXT_FIELD
Constant forTEXT_FIELD
alignment.static int
TIMEZONE_FIELD
Constant forTIMEZONE_FIELD
alignment.static int
WEEK_OF_MONTH_FIELD
Constant forWEEK_OF_MONTH_FIELD
alignment.static int
WEEK_OF_YEAR_FIELD
Constant forWEEK_OF_YEAR_FIELD
alignment.static int
YEAR_FIELD
Constant forYEAR_FIELD
alignment.
-
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 Object
clone()
Overrides theclone
method.boolean
equals(Object obj)
Overrides theequals
method.StringBuffer
format(Object obj, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats an object into a date/time string.String
format(Date date)
Formats aDate
object into a date/time string.abstract StringBuffer
format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats aDate
object into a date/time string.Calendar
getCalendar()
Returns the calendar associated with this date/time formatter.static OraDateFormat
getDateInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateInstance(int, Locale)
static OraDateFormat
getDateInstance(int style)
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateInstance(int, Locale)
static OraDateFormat
getDateInstance(int style, Locale locale)
Returns a date formatter that uses the given date formatting style for the given locale.static OraDateFormat
getDateInstance(int style, OraLocaleInfo localeInfo)
Returns a date formatter that uses the given date formatting style for the givenOraLocaleInfo
object.static OraDateFormat
getDateTimeInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateTimeInstance(int, Locale)
static OraDateFormat
getDateTimeInstance(int dateStyle)
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateTimeInstance(int, Locale)
static 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.static 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 givenOraLocaleInfo
object.static String
getDefaultDateFormatPattern(int style, Locale locale)
Returns the default date format pattern for the given date formatting style and the given locale.static String
getDefaultDateFormatPattern(int style, OraLocaleInfo localeInfo)
Returns the default date format pattern for the given date formatting style and the givenOraLocaleInfo
object.static String
getDefaultDateTimeFormatPattern(int dateStyle, Locale locale)
Returns the default date/time format pattern for the given date formatting style and the given locale.static String
getDefaultDateTimeFormatPattern(int dateStyle, OraLocaleInfo localeInfo)
Returns the default date/time format pattern for the given date formatting style and the givenOraLocaleInfo
object.static String
getDefaultTimeFormatPattern(Locale locale)
Returns the default time format pattern for the given locale.static String
getDefaultTimeFormatPattern(OraLocaleInfo localeInfo)
Returns the default time format pattern for the givenOraLocaleInfo
object.static OraDateFormat
getInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetDateTimeInstance(int, Locale)
static OraDateFormat
getTimeInstance()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced bygetTimeInstance(Locale)
static OraDateFormat
getTimeInstance(Locale locale)
Returns a time formatter for the given locale.static OraDateFormat
getTimeInstance(OraLocaleInfo localeInfo)
Returns a time formatter for the givenOraLocaleInfo
object.TimeZone
getTimeZone()
Returns the time zone associated with the calendar of this formatter.Date
parse(String text)
Parses a date/time string into a date.abstract Date
parse(String text, ParsePosition pos)
Parses a date/time string into a date, starting from the given parse position.Object
parseObject(String text, ParsePosition pos)
Parses a date/time string into a (Date
) object, starting from the given parse position.void
setCalendar(Calendar calendar)
Sets the given calendar to be used by this date/time formatter.void
setTimeZone(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_FIELD
alignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
YEAR_FIELD
public static final int YEAR_FIELD
Constant forYEAR_FIELD
alignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
MONTH_FIELD
public static final int MONTH_FIELD
Constant forMONTH_FIELD
alignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
DATE_FIELD
public static final int DATE_FIELD
Constant forDATE_FIELD
alignment. 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_FIELD
alignment. Used to specify the field position for formatting. TheHOUR_OF_DAY_FIELD
is used for zero-base, 24-hour clock (0 ~ 23).- See Also:
- Constant Field Values
-
MINUTE_FIELD
public static final int MINUTE_FIELD
Constant forMINUTE_FIELD
alignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
SECOND_FIELD
public static final int SECOND_FIELD
Constant forSECOND_FIELD
alignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
MILLISECOND_FIELD
public static final int MILLISECOND_FIELD
Constant forMILLISECOND_FIELD
alignment. 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_FIELD
alignment. 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_FIELD
alignment. 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_FIELD
alignment. 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_FIELD
alignment. 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_FIELD
alignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
HOUR_FIELD
public static final int HOUR_FIELD
Constant forHOUR_FIELD
alignment. Used to specify the field position for formatting. TheHOUR_FIELD
is used for one-base, 12-hour clock (1 ~ 12).- See Also:
- Constant Field Values
-
TIMEZONE_FIELD
public static final int TIMEZONE_FIELD
Constant forTIMEZONE_FIELD
alignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
ALL_FIELD
public static final int ALL_FIELD
Constant forALL_FIELD
alignment. Used to specify the field position for formatting. TheALL_FIELD
is 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_FIELD
alignment. 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_FIELD
alignment. 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_FIELD
alignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
SECONDS_FIELD
public static final int SECONDS_FIELD
Constant forSECONDS_FIELD
alignment. Used to specify the field position for formatting. TheSECONDS_FIELD
is for number of seconds past midnight.- See Also:
- Constant Field Values
-
TEXT_FIELD
public static final int TEXT_FIELD
Constant forTEXT_FIELD
alignment. 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_FIELD
alignment. 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_FIELD
alignment. Used to specify the field position for formatting.- See Also:
- Constant Field Values
-
SHORT
public static final int SHORT
Constant for date/timeSHORT
format style.- See Also:
- Constant Field Values
-
LONG
public static final int LONG
Constant for dateLONG
format style.- See Also:
- Constant Field Values
-
DEFAULT
public static final int DEFAULT
Constant forDEFAULT
format style. For date, it is equivalent to Oracle server default date format. For time, it is equivalent to the timeSHORT
format style.- See Also:
- Constant Field Values
-
calendar
protected Calendar calendar
The calendar that thisOraDateFormat
object uses to calculate the date/time field values. Subclasses should initialize thecalendar
object accordingly based on the locale associated with thisOraDateFormat
object.
-
-
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
,LONG
orDEFAULT
- 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
,LONG
orDEFAULT
locale
- 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 givenOraLocaleInfo
object.- Parameters:
style
- the given date formatting style; options areSHORT
,LONG
orDEFAULT
localeInfo
- the givenOraLocaleInfo
object- 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
,LONG
orDEFAULT
- 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
,LONG
orDEFAULT
locale
- 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 givenOraLocaleInfo
object.- Parameters:
dateStyle
- the given date formatting style; options areSHORT
,LONG
orDEFAULT
localeInfo
- the givenOraLocaleInfo
object- 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 givenOraLocaleInfo
object.- Parameters:
localeInfo
- the givenOraLocaleInfo
object- Returns:
- a time formatter
-
format
public final String format(Date date)
Formats aDate
object 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 aDate
object 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:
format
in classFormat
- Parameters:
obj
- the object to be formatted into a date/time string. It must be an instance ofDate
orNumber
class.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 ofDate
class nor an instance ofNumber
class
-
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
Date
object 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 aDate
object
-
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
Date
object
-
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:
parseObject
in 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 givenOraLocaleInfo
object.- Parameters:
style
- the given date formatting stylelocaleInfo
- the givenOraLocaleInfo
object- 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 givenOraLocaleInfo
object.- Parameters:
dateStyle
- the given date formatting stylelocaleInfo
- the givenOraLocaleInfo
object- 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 givenOraLocaleInfo
object.- Parameters:
localeInfo
- the givenOraLocaleInfo
object- Returns:
- the default time format pattern
-
getCalendar
public Calendar getCalendar()
Returns the calendar associated with this date/time formatter.- Returns:
- the
Calendar
object 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 givenCalendar
object to be used by this formatter
-
getTimeZone
public TimeZone getTimeZone()
Returns the time zone associated with the calendar of this formatter.- Returns:
- the
TimeZone
object 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 givenTimeZone
object to be used by the calendar of this formatter
-
clone
public Object clone()
Overrides theclone
method.
-
-