Oracle® Globalization Development Kit Java API Reference
10g Release 1(10.1)

B10971-01

oracle.i18n.text
Class OraDateFormat

java.lang.Object
  |
  +--java.text.Format
        |
        +--oracle.i18n.text.OraDateFormat
All Implemented Interfaces:
Cloneable, Serializable
Direct Known Subclasses:
OraSimpleDateFormat

public abstract class OraDateFormat
extends Format

OraDateFormat is an abstract class to do locale sensitive formatting and parsing between datetime and string locale dependently. It supports Oracle datetime formatting behavior.

See Also:
OraSimpleDateFormat, Serialized Form

Nested Class Summary

 

Nested classes inherited from class java.text.Format
Format.Field

 

Field Summary
static int ALL_FIELD
          Constant for ALL field alignment.
static int AM_PM_FIELD
          Constant for AM_PM field alignment.
protected  Calendar calendar
          The calendar that this OraDateFormat uses to calculate the datetime field values.
static int CENTRY_FIELD
          Constant for CENTRY field alignment.
static int DATE_FIELD
          Constant for DATE field alignment.
static int DAY_OF_WEEK_FIELD
          Constant for DAY_OF_WEEK field alignment.
static int DAY_OF_YEAR_FIELD
          Constant for DAY_OF_YEAR field alignment.
static int DEFAULT
          Constant for DEFAULT format.
static int ERA_FIELD
          Constant for ERA field alignment.
static int HOUR_FIELD
          Constant for HOUR field alignment Used in FieldPosition of formatting.
static int HOUR_OF_DAY_FIELD
          Constant for HOUR_OF_DAY field alignment.
static int ISO_WEEK_OF_YEAR_FIELD
          Constant for ISO_WEEK_OF_YEAR field alignment.
static int ISO_YEAR_FIELD
          Constant for ISO_YEAR field alignment.
static int JULIAN_DAY_FIELD
          Constant for JULIAN_DAY field alignment.
static int LONG
          Constant for date/time LONG format style.
static int MILLISECOND_FIELD
          Constant for MILLISECOND field alignment.
static int MINUTE_FIELD
          Constant for MINUTE field alignment.
static int MONTH_FIELD
          Constant for MONTH field alignment.
static int QUARTER_OF_YEAR_FIELD
          Constant for QUARTER_OF_YEAR field alignment.
static int SECOND_FIELD
          Constant for SECOND field alignment.
static int SECONDS_FIELD
          Constant for SECONDS field alignment.
static int SHORT
          Constant for date/time SHORT format style.
static int TEXT_FIELD
          Constant for TEXT field alignment.
static int TIMEZONE_FIELD
          Constant for TIMEZONE field alignment.
static int WEEK_OF_MONTH_FIELD
          Constant for WEEK_OF_MONTH field alignment.
static int WEEK_OF_YEAR_FIELD
          Constant for WEEK_OF_YEAR field alignment.
static int YEAR_FIELD
          Constant for YEAR field alignment.

 

Constructor Summary
OraDateFormat()
           

 

Method Summary
 Object clone()
          Overrides Cloneable.
 boolean equals(Object obj)
          Overrides equals.
 String format(Date date)
          Formats a Date into a datetime string.
abstract  StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
          Formats a Date into a datetime string.
 StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition fieldPosition)
          Formats an Object into a datetime string.
 Calendar getCalendar()
          Returns the calendar associated with this datetime formatter.
static oracle.i18n.text.OraDateFormat getDateInstance()
          Returns a date formatter that uses the DEFAULT date formatting style for the default locale.
static oracle.i18n.text.OraDateFormat getDateInstance(int style)
          Returns a date formatter that uses the given date formatting style for the default locale.
static oracle.i18n.text.OraDateFormat getDateInstance(int style, Locale locale)
          Returns a date formatter that uses the given date formatting style for the given locale.
static oracle.i18n.text.OraDateFormat getDateInstance(int style, oracle.i18n.util.OraLocaleInfo localeInfo)
          Returns a date formatter that uses the given date formatting style for the given OraLocaleInfo.
static oracle.i18n.text.OraDateFormat getDateTimeInstance()
          Returns a datetime formatter that uses the DEFAULT formatting style for the default locale.
static oracle.i18n.text.OraDateFormat getDateTimeInstance(int dateStyle)
          Returns a datetime formatter that uses the given date formatting style and the default time formatting style for the default locale.
static oracle.i18n.text.OraDateFormat getDateTimeInstance(int dateStyle, Locale locale)
          Returns a datetime formatter that uses the given date formatting style and the default time formatting style for the given locale.
static oracle.i18n.text.OraDateFormat getDateTimeInstance(int dateStyle, oracle.i18n.util.OraLocaleInfo localeInfo)
          Returns a datetime formatter that uses the given date formatting style and the default time formatting style for the given OraLocaleInfo.
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, oracle.i18n.util.OraLocaleInfo localeInfo)
          Returns the default date format pattern for the given date formatting style and the given OraLocaleInfo.
static String getDefaultDateTimeFormatPattern(int dateStyle, Locale locale)
          Returns the default datetime format pattern for the given date formatting style and the given locale.
static String getDefaultDateTimeFormatPattern(int dateStyle, oracle.i18n.util.OraLocaleInfo localeInfo)
          Returns the default datetime format pattern for the given date formatting style and the given OraLocaleInfo.
static String getDefaultTimeFormatPattern(Locale locale)
          Returns the default time format pattern for the given locale.
static String getDefaultTimeFormatPattern(oracle.i18n.util.OraLocaleInfo localeInfo)
          Returns the default time format pattern for the given OraLocaleInfo.
static oracle.i18n.text.OraDateFormat getInstance()
          Returns a datetime formatter that uses the DEFAULT style for the default locale.
static oracle.i18n.text.OraDateFormat getTimeInstance()
          Returns a time formatter for the default locale.
static oracle.i18n.text.OraDateFormat getTimeInstance(Locale locale)
          Returns a time formatter for the given locale.
static oracle.i18n.text.OraDateFormat getTimeInstance(oracle.i18n.util.OraLocaleInfo localeInfo)
          Returns a time formatter for the given OraLocaleInfo.
 TimeZone getTimeZone()
          Returns the timezone associated with the calendar of this formatter.
 Date parse(String text)
          Parses a datetime string into a Date.
abstract  Date parse(String text, ParsePosition pos)
          Parses a datetime string into a Date, starting from the given parse position.
 Object parseObject(String text, ParsePosition pos)
          Parses a datetime string into a (Date) Object, starting from the given parse position.
 void setCalendar(Calendar calendar)
          Sets the given calendar to be used by this datetime formatter.
 void setTimeZone(TimeZone timezone)
          Sets the given timezone to be used by the calendar of this formatter.

 

Methods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject

 

Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

ERA_FIELD

public static final int ERA_FIELD
Constant for ERA field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

YEAR_FIELD

public static final int YEAR_FIELD
Constant for YEAR field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

MONTH_FIELD

public static final int MONTH_FIELD
Constant for MONTH field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

DATE_FIELD

public static final int DATE_FIELD
Constant for DATE field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

HOUR_OF_DAY_FIELD

public static final int HOUR_OF_DAY_FIELD
Constant for HOUR_OF_DAY field alignment. Used in FieldPosition of formatting. HOUR_OF_DAY is used for zero-base 24-hour clock (0 ~ 23).
See Also:
Constant Field Values

MINUTE_FIELD

public static final int MINUTE_FIELD
Constant for MINUTE field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

SECOND_FIELD

public static final int SECOND_FIELD
Constant for SECOND field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

MILLISECOND_FIELD

public static final int MILLISECOND_FIELD
Constant for MILLISECOND field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

DAY_OF_WEEK_FIELD

public static final int DAY_OF_WEEK_FIELD
Constant for DAY_OF_WEEK field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

DAY_OF_YEAR_FIELD

public static final int DAY_OF_YEAR_FIELD
Constant for DAY_OF_YEAR field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

WEEK_OF_YEAR_FIELD

public static final int WEEK_OF_YEAR_FIELD
Constant for WEEK_OF_YEAR field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

WEEK_OF_MONTH_FIELD

public static final int WEEK_OF_MONTH_FIELD
Constant for WEEK_OF_MONTH field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

AM_PM_FIELD

public static final int AM_PM_FIELD
Constant for AM_PM field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

HOUR_FIELD

public static final int HOUR_FIELD
Constant for HOUR field alignment Used in FieldPosition of formatting. HOUR is used for one-base 12-hour clock (1 ~ 12).
See Also:
Constant Field Values

TIMEZONE_FIELD

public static final int TIMEZONE_FIELD
Constant for TIMEZONE field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

ALL_FIELD

public static final int ALL_FIELD
Constant for ALL field alignment. Used in FieldPosition of formatting. ALL 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 for CENTRY field alignment. Used in FieldPosition of 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 for JULIAN_DAY field alignment. Used in FieldPosition of formatting. JULIAN_DAY is used for 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 for QUARTER_OF_YEAR field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

SECONDS_FIELD

public static final int SECONDS_FIELD
Constant for SECONDS field alignment. Used in FieldPosition of formatting. SECONDS is for seconds past midnight
See Also:
Constant Field Values

TEXT_FIELD

public static final int TEXT_FIELD
Constant for TEXT field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

ISO_YEAR_FIELD

public static final int ISO_YEAR_FIELD
Constant for ISO_YEAR field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

ISO_WEEK_OF_YEAR_FIELD

public static final int ISO_WEEK_OF_YEAR_FIELD
Constant for ISO_WEEK_OF_YEAR field alignment. Used in FieldPosition of formatting.
See Also:
Constant Field Values

SHORT

public static final int SHORT
Constant for date/time SHORT format style.
See Also:
Constant Field Values

LONG

public static final int LONG
Constant for date/time LONG format style.
See Also:
Constant Field Values

DEFAULT

public static final int DEFAULT
Constant for DEFAULT format. For date, it is equivalent to Oracle server default date format. For time, it is equivalent to time SHORT format style.
See Also:
Constant Field Values

calendar

protected Calendar calendar
The calendar that this OraDateFormat uses to calculate the datetime field values. Subclasses should initialize it accordingly based on the locale associated with this OraDateFormat.
Constructor Detail

OraDateFormat

public OraDateFormat()
Method Detail

getDateInstance

public static final oracle.i18n.text.OraDateFormat getDateInstance()
Returns a date formatter that uses the DEFAULT date formatting style for the default locale.
Returns:
a date formatter.

getDateInstance

public static final oracle.i18n.text.OraDateFormat getDateInstance(int style)
Returns a date formatter that uses the given date formatting style for the default locale.
Parameters:
style - the given date formatting style.
Returns:
a date formatter.
Throws:
IllegalArgumentException - if the given date formatting style is invalid.

getDateInstance

public static final oracle.i18n.text.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.
locale - the given locale.
Returns:
a date formatter.
Throws:
IllegalArgumentException - if the given date formatting style is invalid.

getDateInstance

public static final oracle.i18n.text.OraDateFormat getDateInstance(int style,
                                                                   oracle.i18n.util.OraLocaleInfo localeInfo)
Returns a date formatter that uses the given date formatting style for the given OraLocaleInfo.
Parameters:
style - the given date formatting style.
localeInfo - the given OraLocaleInfo.
Returns:
a date formatter.
Throws:
IllegalArgumentException - if the given date formatting style is invalid.

getDateTimeInstance

public static final oracle.i18n.text.OraDateFormat getDateTimeInstance()
Returns a datetime formatter that uses the DEFAULT formatting style for the default locale.
Returns:
a date formatter.

getDateTimeInstance

public static final oracle.i18n.text.OraDateFormat getDateTimeInstance(int dateStyle)
Returns a datetime 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.
Returns:
a date formatter.
Throws:
IllegalArgumentException - if the given date formatting style is invalid.

getDateTimeInstance

public static final oracle.i18n.text.OraDateFormat getDateTimeInstance(int dateStyle,
Locale locale)
Returns a datetime 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.
locale - the given locale.
Returns:
a date formatter.
Throws:
IllegalArgumentException - if the given date formatting style is invalid.

getDateTimeInstance

public static final oracle.i18n.text.OraDateFormat getDateTimeInstance(int dateStyle,
                                                                       oracle.i18n.util.OraLocaleInfo localeInfo)
Returns a datetime formatter that uses the given date formatting style and the default time formatting style for the given OraLocaleInfo.
Parameters:
dateStyle - the given date formatting style.
localeInfo - the given OraLocaleInfo.
Returns:
a date formatter.
Throws:
IllegalArgumentException - if the given date formatting style is invalid.

getInstance

public static final oracle.i18n.text.OraDateFormat getInstance()
Returns a datetime formatter that uses the DEFAULT style for the default locale.
Returns:
a datetime formatter.

getTimeInstance

public static final oracle.i18n.text.OraDateFormat getTimeInstance()
Returns a time formatter for the default locale.
Returns:
a datetime formatter.

getTimeInstance

public static final oracle.i18n.text.OraDateFormat getTimeInstance(Locale locale)
Returns a time formatter for the given locale.
Returns:
a datetime formatter.

getTimeInstance

public static final oracle.i18n.text.OraDateFormat getTimeInstance(oracle.i18n.util.OraLocaleInfo localeInfo)
Returns a time formatter for the given OraLocaleInfo.
Parameters:
localeInfo - the given OraLocaleInfo.
Returns:
a datetime formatter.

format

public final String format(Date date)
Formats a Date into a datetime string.
Parameters:
date - the datetime object to be formatted into a datetime string.
Returns:
the formatted datatime string.

format

public abstract StringBuffer format(Date date,
StringBuffer toAppendTo,
FieldPosition fieldPosition)
Formats a Date into a datetime string. Sets field position if it is needed.
Parameters:
date - the datetime object to be formatted into a datetime string.
toAppendTo - the string buffer to be appended with the formatted datetime 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 to be returned. On output: the offsets of the alignment field in the returned string buffer.
Returns:
the string buffer appended with the formatted datatime string.

format

public final StringBuffer format(Object obj,
StringBuffer toAppendTo,
FieldPosition fieldPosition)
Formats an Object into a datetime string. Sets field position if it is needed.
Specified by:
format in class Format
Parameters:
obj - the object to be formatted into a datetime string. It must be an instance of Date or Number.
toAppendTo - the string buffer to be appended with the formatted datetime 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 to be returned. On output: the offsets of the alignment field in the returned string buffer.
Returns:
the string buffer appended with the formatted datatime string.
Throws:
IllegalArgumentException - if the given object is neither an instance of Date nor an instance of Number.

parse

public Date parse(String text)
           throws ParseException
Parses a datetime string into a Date.
Parameters:
text - the datetime string to be parsed.
Returns:
a Date corresponding to the datatime string.
Throws:
ParseException - if the format pattern associated with this fromatter is not valid for parsing or the given datetime string can not be parsed into a Date.

parse

public abstract Date parse(String text,
ParsePosition pos)
Parses a datetime string into a Date, starting from the given parse position.
Parameters:
text - the datetime 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 fails.
Returns:
a Date.
Throws:
IllegalArgumentException - if the format pattern associated with this fromatter is not valid for parsing or the given datetime string can not be parsed into a Date.

parseObject

public Object parseObject(String text,
ParsePosition pos)
Parses a datetime string into a (Date) Object, starting from the given parse position. It is a convenient method which simply calls parse(String, ParsePostion).
Specified by:
parseObject in class Format
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:
locale - the given locale.
Returns:
the default date format pattern.
Throws:
IllegalArgumentException - if the given date formatting style is invalid.

getDefaultDateFormatPattern

public static String getDefaultDateFormatPattern(int style,
                                                 oracle.i18n.util.OraLocaleInfo localeInfo)
Returns the default date format pattern for the given date formatting style and the given OraLocaleInfo.
Parameters:
localeInfo - the given OraLocaleInfo.
Returns:
the default date format pattern.
Throws:
IllegalArgumentException - if the given date formatting style is invalid.

getDefaultDateTimeFormatPattern

public static String getDefaultDateTimeFormatPattern(int dateStyle,
Locale locale)
Returns the default datetime format pattern for the given date formatting style and the given locale.
Parameters:
dateStyle - the given date formatting style.
locale - the given locale.
Returns:
the default datetime format pattern.
Throws:
IllegalArgumentException - if the given date formatting style is invalid.

getDefaultDateTimeFormatPattern

public static String getDefaultDateTimeFormatPattern(int dateStyle,
                                                     oracle.i18n.util.OraLocaleInfo localeInfo)
Returns the default datetime format pattern for the given date formatting style and the given OraLocaleInfo.
Parameters:
dateStyle - the given date formatting style.
localeInfo - the given OraLocaleInfo.
Returns:
the default datetime format pattern.
Throws:
IllegalArgumentException - if the given date formatting style is invalid.

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(oracle.i18n.util.OraLocaleInfo localeInfo)
Returns the default time format pattern for the given OraLocaleInfo.
Parameters:
localeInfo - the given OraLocaleInfo.
Returns:
the default time format pattern.

getCalendar

public Calendar getCalendar()
Returns the calendar associated with this datetime formatter.
Returns:
the calendar associated with this formatter.

setCalendar

public void setCalendar(Calendar calendar)
Sets the given calendar to be used by this datetime formatter.
Parameters:
calendar - the given calendar to be used by this formatter.

getTimeZone

public TimeZone getTimeZone()
Returns the timezone associated with the calendar of this formatter.
Returns:
the timezone associated with the calendar of this formatter.

setTimeZone

public void setTimeZone(TimeZone timezone)
Sets the given timezone to be used by the calendar of this formatter.
Parameters:
timezone - the given timezone to be used by the calendar of this formatter.

clone

public Object clone()
Overrides Cloneable.
Overrides:
clone in class Format

equals

public boolean equals(Object obj)
Overrides equals.
Overrides:
equals in class Object

Oracle® Globalization Development Kit Java API Reference
10g Release 1(10.1)

B10971-01

Copyright © 2003 Oracle Corporation. All Rights Reserved.