flash.globalizationDateTimeFormatter The DateTimeFormatter class provides locale-sensitive formatting for Date objects and access to localized date field names.Object The DateTimeFormatter class provides locale-sensitive formatting for Date objects and access to localized date field names. The methods of this class use functions and settings provided by the operating system.

There are two ways to select a date time format: using a predefined pattern or a custom pattern. For most applications the predefined styles specified by the DateTimeStyle constants (LONG, MEDIUM, NONE, or SHORT should be used. These constants specify the default patterns for the requested locale or the default patterns based on the user's operating system settings.

For example the following code creates a date string using the default short date format:

var df:DateTimeFormatter = new DateTimeFormatter(LocaleID.DEFAULT, DateTimeStyle.SHORT, DateTimeStyle.NONE); var currentDate:Date = new Date(); var shortDate:String = df.format(currentDate);

When an instance of this class is created, if the requested locale is supported by the operating system then the properties of the instance are set according to the conventions and defaults of the requested locale and the constructor's dateStyle and timeStyle parameters. If the requested locale is not available, then the properties are set according to a fallback or default system locale, which can be retrieved using the actualLocaleIDName property.

This class contains additional methods to get localized strings for month names and weekday names, and to retrieve the first day of the week that can be used in a calendar picker or other similar application.

Due to the use of the user's settings, the use of formatting patterns provided by the operating system, and the use of a fallback locale when a requested locale is not supported, different users can see different formatting results even when using the same locale ID.

The following examples shows how strings that represent date and time values can be formatted differently based on the locale. The output from this example will differ based on the operating system and user preferences.

This example uses the following locales: English (US), French (France), Spanish (Spain).

The example does the following for each locale in the list:

  1. Creates a DateTimeFormatter object using the default style (long dateStyle, long timeStyle)
  2. Formats the current date and time using the default long date style.
  3. Change to a time-only short date style using the DateTimeStyle.NONE and DateTimeStyle.SHORT constants.
  4. Formats the current date and time using the time-only short date style.
package { import flash.display.Sprite; import flash.globalization.DateTimeFormatter; import flash.globalization.DateTimeStyle; public class DateTimeFormatterExample extends Sprite { private var localeList:Array = new Array("en-US", "fr-FR", "es-ES"); public function DateTimeFormatterExample() { var date:Date = new Date(); for each (var locale:String in localeList) { var dtf:DateTimeFormatter = new DateTimeFormatter(locale); trace('\n' + "LocaleID requested=" + dtf.requestedLocaleIDName + "; actual=" + dtf.actualLocaleIDName); var longDate:String = dtf.format(date); trace(longDate + " (" + dtf.getDateTimePattern() + ")"); dtf.setDateTimeStyles(DateTimeStyle.NONE, DateTimeStyle.SHORT); var shortDate:String = dtf.format(date); trace(shortDate + " (" + dtf.getDateTimePattern() + ")"); } } } }
The following example shows how an application can format a date based on a pattern selected by the user. The output from this example will differ based on the operating system and user preferences.

The example does the following for each locale in the list:

  1. Creates three input and output text fields.
  2. Creates a DateTimeFormatter object using the American English locale.
  3. Calls the configureTextField() function which sets the position and size of the text fields and adds an event listener to the patternField object.
  4. When the user enters pattern in the patternField text field, the textInputHandler function formats the current date and time using the pattern, and displays the result and the lastOperationStatus value the in output text fields.
package { import flash.display.Sprite; import flash.events.Event; import flash.globalization.DateTimeFormatter; import flash.text.*; public class DateTimePatternExample extends Sprite { private var patternField:TextField = new TextField(); private var resultField:TextField = new TextField(); private var statusField:TextField = new TextField(); private var date:Date = new Date(); private var dtf:DateTimeFormatter = new DateTimeFormatter("en-US"); private function configureTextField():void { patternField.type = TextFieldType.INPUT; patternField.width = 300; patternField.height = 20; patternField.background = true; patternField.border = true; resultField.y = 40; resultField.width = 300; resultField.height = 20; statusField.y = 80; statusField.width = 300; statusField.height = 20; addChild(patternField); addChild(resultField); addChild(statusField); patternField.addEventListener(Event.CHANGE,textInputHandler); } private function textInputHandler(event:Event):void { dtf.setDateTimePattern(patternField.text); statusField.text = dtf.lastOperationStatus; resultField.text = dtf.format(date); } public function DateTimePatternExample() { configureTextField(); } } }
actualLocaleIDNameDateTimeStyleDateTimeFormatter Constructs a new DateTimeFormatter object to format dates and times according to the conventions of the specified locale and the provided date and time formatting styles.if the dateStyle or timeStyle parameter is not a valid DateTimeStyle constant. ArgumentErrorArgumentErrorif the dateStyle or timeStyle parameter is null. TypeErrorTypeErrorrequestedLocaleIDNameStringThe preferred locale ID name to use when determining date or time formats. dateStyleStringlongSpecifies the style to use when formatting dates. The value corresponds to one of the values enumerated by the DateTimeStyle class:
  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE
timeStyleStringlongSpecifies the style to use when formatting times. The value corresponds to one of the values enumerated by the DateTimeStyle class:
  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE
Constructs a new DateTimeFormatter object to format dates and times according to the conventions of the specified locale and the provided date and time formatting styles. Date and time styles are used to set date and time formatting patterns to predefined, locale dependent patterns from the operating system.

This constructor determines if the current operating system supports the requested locale ID name. If it is not supported then a fallback locale is used instead. The name of the fallback locale ID can be determined from the actualLocaleIDName property.

If a fallback is used for any of the requestedLocaleIDName, dateStyle or timeStyle parameters then the lastOperationStatus property is set to indicate the type of fallback.

To format based on the user's current operating system preferences, pass the value LocaleID.DEFAULT in the requestedLocaleIDName parameter to the constructor.

When the constructor is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

When the requested locale ID name is not available then the lastOperationStatus is set to one of the following:

  • LastOperationStatus.USING_FALLBACK_WARNING
  • LastOperationStatus.USING_DEFAULT_WARNING

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

For details on the warnings listed above and other possible values of the lastOperationStatus property see the descriptions in the LastOperationStatus class.

lastOperationStatusrequestedLocaleIDNameactualLocaleIDNameDateTimeStyleLastOperationStatusLocaleID
formatUTC Formats a display string for a Date object that is interpreted as being in UTC time (using the UTC components of the Date object such as: dateUTC, dayUTC, fullYearUTC, hoursUTC, minutesUTC, monthUTC, and secondsUTC), according to the dateStyle, timeStyle or date time pattern.A formatted string representing the date or time value. StringdateTimeDateA Date value to be formatted. Formats a display string for a Date object that is interpreted as being in UTC time (using the UTC components of the Date object such as: dateUTC, dayUTC, fullYearUTC, hoursUTC, minutesUTC, monthUTC, and secondsUTC), according to the dateStyle, timeStyle or date time pattern. The formatting is done using the conventions of the locale ID and the date style and time style, or customized date pattern and time pattern, specified for this DateTimeFormatter instance.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

setDateTimeStyles()setDateTimePattern()getDateStyle()getTimeStyle()lastOperationStatusLastOperationStatus
format Formats a display string for a Date object that is interpreted as being in the user's local time (using the local time components of the Date object such as: date, day, fullYear, hours, minutes, month, and seconds).A formatted string representing the date or time value. StringdateTimeDateA Date value to be formatted. Formats a display string for a Date object that is interpreted as being in the user's local time (using the local time components of the Date object such as: date, day, fullYear, hours, minutes, month, and seconds). The formatting is done using the conventions of the locale ID and the date style and time style, or customized date pattern and time pattern, specified for this DateTimeFormatter instance.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

setDateTimeStyles()setDateTimePattern()getDateStyle()getTimeStyle()lastOperationStatusLastOperationStatus
getAvailableLocaleIDNames Lists all of the locale ID names supported by this class.A vector of strings containing all of the locale ID names supported by this class. Lists all of the locale ID names supported by this class.

If this class is not supported on the current operating system, this method returns a null value.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatusLocaleID
getDateStyle Gets the date style for this instance of the DateTimeFormatter.The date style string for this formatter.

Possible values:

  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE
  • DateTimeStyle.CUSTOM
String
Gets the date style for this instance of the DateTimeFormatter. The date style is used to retrieve a predefined date formatting pattern from the operating system. The date style value can be set by the DateTimeFormatter() constructor, the setDateTimeStyles() method or the setDateTimePattern() method.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

setDateTimeStyles()setDateTimePattern()lastOperationStatusDateTimeStyleDateTimeFormatterLastOperationStatus
getDateTimePattern Returns the pattern string used by this DateTimeFormatter object to format dates and times.A string containing the pattern used by this DateTimeFormatter object to format dates and times. String Returns the pattern string used by this DateTimeFormatter object to format dates and times.

This pattern can be set in one of three ways:

  1. By the dateStyle and timeStyle parameters used in the constructor
  2. By the setDateTimeStyles() method
  3. By the setDateTimePattern() method.

For a description of the pattern syntax, see the setDateTimePattern() method.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

DateTimeFormattersetDateTimeStyles()setDateTimePattern()lastOperationStatusLastOperationStatus
getFirstWeekday Returns an integer corresponding to the first day of the week for this locale and calendar system.An integer corresponding to the first day of the week for this locale and calendar system. int Returns an integer corresponding to the first day of the week for this locale and calendar system. A value of 0 corresponds to Sunday, 1 corresponds to Monday, and so on, with 6 corresponding to Saturday.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
getMonthNames Retrieves a list of localized strings containing the month names for the current calendar system.if the nameStyle or context parameter is null. TypeErrorTypeErrorA vector of localized strings containing the month names for the specified locale, name style, and context. The first element in the vector, at index 0, is the name for the first month of the year; the next element is the name for the second month of the year; and so on. nameStyleStringfullIndicates the style of name string to be used. Valid values are:
  • DateTimeNameStyle.FULL
  • DateTimeNameStyle.LONG_ABBREVIATION
  • DateTimeNameStyle.SHORT_ABBREVIATION
contextStringstandaloneA code indicating the context in which the formatted string is used. This context makes a difference only for certain locales. Valid values are:
  • DateTimeNameContext.FORMAT
  • DateTimeNameContext.STANDALONE
Retrieves a list of localized strings containing the month names for the current calendar system. The first element in the list is the name for the first month of the year.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusDateTimeNameContextDateTimeNameStyleLastOperationStatus
getTimeStyle Gets the time style for this instance of the DateTimeFormatter.The time style string for this formatter.

Possible values:

  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE
  • DateTimeStyle.CUSTOM
String
Gets the time style for this instance of the DateTimeFormatter. The time style is used to retrieve a predefined time formatting pattern from the operating system. The time style value can be set by the DateTimeFormatter() constructor, the setDateTimeStyles() method or the setDateTimePattern() method.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

setDateTimeStyles()setDateTimePattern()lastOperationStatusDateTimeStyleDateTimeFormatterLastOperationStatus
getWeekdayNames Retrieves a list of localized strings containing the names of weekdays for the current calendar system.if the nameStyle or context parameter is null. TypeErrorTypeErrorA vector of localized strings containing the month names for the specified locale, name style, and context. The first element in the vector, at index 0, is the name for Sunday; the next element is the name for Monday; and so on. nameStyleStringfullIndicates the style of name string to be used. Valid values are:
  • DateTimeNameStyle.FULL
  • DateTimeNameStyle.LONG_ABBREVIATION
  • DateTimeNameStyle.SHORT_ABBREVIATION
contextStringstandaloneA code indicating the context in which the formatted string is used. This context only applies for certain locales where the name of a month changes depending on the context. For example, in Greek the month names are different if they are displayed alone versus displayed along with a day. Valid values are:
  • DateTimeNameContext.FORMAT
  • DateTimeNameContext.STANDALONE
Retrieves a list of localized strings containing the names of weekdays for the current calendar system. The first element in the list represents the name for Sunday.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusDateTimeNameContextDateTimeNameStyleLastOperationStatus
setDateTimePattern Sets the pattern string used by this DateTimeFormatter object to format dates and times.if the pattern parameter is null. TypeErrorTypeErrorpatternString Sets the pattern string used by this DateTimeFormatter object to format dates and times.

The pattern used to format dates can be set in one of three ways:

  1. By the dateStyle and timeStyle parameters used in the constructor
  2. By the setDateTimeStyles() method
  3. By this setDateTimePattern() method.

As a side effect this method overrides the current time and date styles for this DateTimeFormatter object and set them to the value DateTimeStyle.CUSTOM.

A pattern string defines how date and times are formatted. The pattern contains sequences of letters that are replaced with date and time values in the formatted string. For example, in the pattern "yyyy/MM" the characters "yyyy" are replaced with a four-digit year, followed by a "/" character, and the characters "MM" are replaced with a two-digit month.

Many of the letters used in patterns can be repeated more than once to produce different outputs, as described in the table below.

If a sequence exceeds the maximum number of letters supported by a pattern, it is mapped back to the longest supported sequence for that pattern letter. For example:

  • MMMMMM is replaced with MMMM
  • dddd is replaced with dd
  • EEEEEEE is replaced with EEEE
  • aa is replaced with a
  • hhh is replaced with hh
  • mmmm is replaced with mm

In theory a pattern can contain up to 255 characters, but some platforms have stricter limit. If the pattern exceeds the pattern character limit, the lastOperationStatus property is set to the value LastOperationStatus.PATTERN_SYNTAX_ERROR.

Not all possible patterns are supported on each operating system. If a pattern is not supported on the platform then a fallback pattern is used and the lastOperationStatus property is set to indicate the use of a fallback. If no reasonable fallback pattern can be provided, an empty string is used and the lastOperationStatus property is set to indicate that the pattern was unsupported.

The following table describes the valid pattern letters and their meaning.

Pattern letterDescriptionGEra. Replaced by the Era string for the current date and calendar. This pattern is not supported on all operating systems. On operating systems that do not support the era, the letters of the input pattern are replaced by an empty string.

There can be one to five letters in era patterns that are interpreted as follows:

  • If the number of pattern letters is one to three, the abbreviated form is used.
  • If the number of pattern letters is four, the format is interpreted as the full form.
  • If the number of pattern letters is five, the format is interpreted as the short abbreviation.

Examples with the Gregorian Calendar(for operating systems that support this pattern):

  • G, GG, GGG = AD
  • GGGG = Anno Domini
  • GGGGG = A
yYear. If the number of pattern letters is two, the last two digits of the year are displayed; otherwise the number of letters determines the number of digits. If the year value requires more digits than provided by the number of letters, then the full year value is provided. If there are more letters than required by the value, then the year values are padded with zeros. The following list shows the results for the years 1 and 2005.

Examples:

  • y = 1
  • y = 2005
  • yy = 01
  • yy = 05
  • yyyy = 0001 or 01, Depending on the operating system.
  • yyyy = 2005
  • yyyyy = 01 or 0001, Depending on the operating system. More than four y's fall back to the maximum number of digits supported on the operating system.
  • yyyyy = 2005
M Month in year. There can be one to five letters in month patterns that are interpreted as follows:
  • If the number of pattern letters is one, the format is interpreted as numeric in one or two digits.
  • If the number of pattern letters is two, the format is interpreted as numeric in two digits.
  • If the number of pattern letters is three, the format is interpreted as the long abbreviation.
  • If the number of pattern letters is four, the format is interpreted as the full name.
  • If the number of pattern letters is five, the format is interpreted as the short abbreviation. This format is not supported on all operating systems and falls back to the long abbreviation.

Examples:

  • M = 7
  • MM = 07
  • MMM = Jul, 7月
  • MMMM = July, 7月
  • MMMMM = J or Jul, 7 or 7月 depending on the operating system.
d Day of the month. There can be one or two letters in day of the month patterns that are interpreted as follows:
  • If the number of pattern letters is one, the format is interpreted as numeric in one or two digits.
  • If the number of pattern letters is two, the format is interpreted as numeric in two digits.

Examples:

  • d = 4
  • dd = 04
  • dd = 14
EDay in week. There can be one to five letters in day of the week patterns that are interpreted as follows:
  • If the number of pattern letters is one to three, the format is interpreted as the long abbreviation.
  • If the number of pattern letters is four, the format is interpreted as the full name.
  • If the number of pattern letters is five, the format is interpreted as the short abbreviation. This format is not supported on all operating systems and falls back to the long abbreviation.

Examples:

  • E, EE, EEE = Tues
  • EEEE = Tuesday
  • EEEEE = T or Tues depending on the operating system.
QQuarter. Some platforms do not support this pattern. There can be one to four letters in quarter patterns that are interpreted as follows:
  • If the number of pattern letters is one, the format is interpreted as numeric in one digit.
  • If the number of pattern letters is two, the format is interpreted as numeric in two digits.
  • If the number of pattern letters is three, the format is interpreted as the abbreviation.
  • If the number of pattern letters is four, the format is interpreted as the full name.

Examples (for operating systems that support this pattern):

  • Q = 2
  • QQ = 02
  • QQQ = Q2
  • QQQQ = second quarter
wWeek of the year. Some platforms do not support this pattern. There can be one to two letters in this pattern that are interpreted as follows.
  • If the number of pattern letters is one, the format is interpreted as numeric in one or two digits.
  • If the number of pattern letters is two, the format is interpreted as numeric in two digits.

Examples for the second week of the year (for operating systems that support this pattern):

  • w = 2
  • ww = 02
WWeek of the month. Some platforms do not support this pattern. This pattern allows one letter only.

Examples for the second week of July (for operating systems that support this pattern):

  • W = 2
DDay of the year. Some platforms do not support this pattern. There can be one to three letters in this pattern.

Examples for the second day of the year (for operating systems that support this pattern):

  • D = 2
  • DD = 02
  • DDD = 002
FOccurrence of a day of the week within a calendar month. For example, this element displays "3" if used to format the date for the third Monday in October. This pattern allows one letter only.

Examples for the second Wednesday in July (for operating systems that support this pattern):

  • F = 2
aAM/PM indicator. This pattern allows one letter only, a or p.

Examples:

  • a = AM, 午前
  • p = PM, 午後
hHour of the day in a 12-hour format [1 - 12]. This pattern must be one or two letters.

Examples:

  • h = 1
  • h = 12
  • hh = 01
HHour of the day in a 24-hour format [0 - 23]. This pattern must be one or two letters.

Examples:

  • H = 0
  • H = 23
  • HH = 00
KHour in the day in a 12-hour format [0 - 11]. This pattern must be one or two letters. This pattern is not supported on all operating systems.

Examples (for operating systems that support this pattern):

  • K = 0
  • K = 11
  • KK = 00
kHour of the day in a 24-hour format [1 - 24]. This pattern must be one or two letters. This pattern is not supported on all operating systems.

Examples (for operating systems that support this pattern):

  • k = 1
  • k = 24
  • kk = 01
mMinute of the hour [0 - 59]. This pattern must be one or two letters.

Examples:

  • m = 2
  • m = 59
  • mm = 02
sSeconds in the minute [0 - 59]. This pattern must be one or two letters.

Examples:

  • s = 2
  • s = 59
  • ss = 02
SMilliseconds. This pattern must be one to five letters. The value is rounded according to the number of letters used. When five characters are used (SSSSS) it denotes fractional milliseconds.

Examples:

  • S = 2
  • SS = 24
  • SSS = 235
  • SSSS = 2350
  • SSSSS = 23500
zTime Zone. Represents the time zone as a string that respects standard or daylight time, without referring to a specific location. This pattern is not supported on all operating systems. On operating systems that do not support time zone patterns, the letters of the input pattern are replaced by an empty string. On operating systems that do support this pattern, not all locales have a defined string. Those locales fall back to a localized GMT format such as GMT-08:00 or GW-08:00

There must be one to four letters in this time zone pattern, interpreted as follows:

  • If the number of pattern letters is one to three, the format is interpreted as abbreviated form.
  • If the number of pattern letters is four, the format is interpreted as the full name.

Examples for operating systems that support this format:

  • z, zz, zzz = PDT
  • z, zz, zzz = PST
  • z, zz, zzz = GMT-0800
  • zzzz = Pacific Daylight Time
  • zzzz = Pacific Standard Time
ZTime Zone. Represents the time zone as an offset from GMT. This pattern is not supported on all operating systems. On operating systems that do not support time zone patterns, the letters of the input pattern are replaced by an empty string.

There must be one to four letters in this time zone pattern, interpreted as follows:

  • If the number of pattern letters is one to three, the format uses the RFC 822 format.
  • If the number of pattern letters is four, the format uses the localized GMT format. This falls back to the non-localized GMT format for locales that do not have a localized GMT format.

Examples for operating systems that support this format:

  • Z, ZZ, ZZZ = -0800
  • ZZZZ = GMT-08:00, GW-08:00
vTime Zone. A string reflecting the generic time zone that does not refer to a specific location or distinguish between daylight savings time or standard time. This pattern is not supported on all operating systems. On operating systems that do not support time zone patterns the letters of the input pattern are replaced by an empty string. On operating systems that support this pattern, fallback strings are provided if a localized name is not available.

There must be one or four letters in this time zone pattern, interpreted as follows:

  • If the number of pattern letters is one, the format uses the abbreviated form.
  • If the number of pattern letters is four, the format uses the full form.

Examples for operating systems that support this format:

  • v = PT
  • vvvv = Pacific Time
'Other text'Text and punctuation may be included in the pattern string. However the characters from a to z and A to Z, are reserved as syntax characters and must be enclosed in single quotes to be included in the formatted string. To include a single quote in the result string, two single quotes must be used in the pattern string. The two single quotes may appear inside or outside a quoted portion of the pattern string. An unmatched pair of single quotes is terminated at the end of the string.

Examples:

  • EEEE, MMM. d, yyyy 'at' h 'o''clock' a= Tuesday, Sept. 8, 2005 at 1 o'clock PM
  • yyyy年M月d日 = 2005年9月8日
  • mm''ss'' = 43'01'

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

DateTimeFormattersetDateTimeStyles()setDateTimePattern()lastOperationStatusLastOperationStatus
setDateTimeStyles Sets the date and time styles for this instance of the DateTimeFormatter.if the dateStyle or timeStyle parameter is not a valid DateTimeStyle constant. ArgumentErrorArgumentErrorif the dateStyle or timeStyle parameter is null. TypeErrorTypeErrordateStyleStringSpecifies the style to use when formatting dates. The value corresponds to one of the values enumerated by the DateTimeStyle class:
  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE
timeStyleStringSpecifies the style to use when formatting times. The value corresponds to one of the values enumerated by the DateTimeStyle class:
  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE
Sets the date and time styles for this instance of the DateTimeFormatter. Date and time styles are used to set date and time formatting patterns to predefined, locale-dependent patterns from the operating system. This method replaces the styles that were set using the DateTimeFormatter() constructor or using the setDateTimePattern() method. The date and time pattern is also updated based on the styles that are set.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

DateTimeFormatter()setDateTimeStyles()setDateTimePattern()lastOperationStatusDateTimeStyleLastOperationStatus
actualLocaleIDName The name of the actual locale ID used by this DateTimeFormatter object.String The name of the actual locale ID used by this DateTimeFormatter object.

There are three possibilities for the value of the name, depending on operating system and the value of the requestedLocaleIDName parameter passed to the Collator() constructor.

  1. If the requested locale was not LocaleID.DEFAULT and the operating system provides support for the requested locale, then the name returned is the same as the requestedLocaleIDName property.
  2. If LocaleID.DEFAULT was used as the value for the requestedLocaleIDName parameter to the constructor, then the name of the current locale specified by the user's operating system is used. The LocaleID.DEFAULT value preserves user's customized setting in the OS. Passing an explicit value as the requestedLocaleIDName parameter does not necessarily give the same result as using the LocaleID.DEFAULT even if the two locale ID names are the same. The user might have customized the locale settings on their machine, and by requesting an explicit locale ID name rather than using LocaleID.DEFAULT your application would not retrieve those customized settings.

    For example:

    var fmt:DateTimeFormatter = new DateTimeFormatter(LocaleID.DEFAULT); var aliName:String = fmt.actualLocaleIDName;

    In the above example, aliName is the name of the locale corresponding to the user's current operating systems settings (e.g. "it-IT" if the user's locale is set to Italian-Italy), and not "i-default" (the name of the LocaleID.DEFAULT locale).

  3. If the system does not support the requestedLocaleIDName specified in the constructor then a fallback locale ID name is provided.

    For Example:

    var fmt:DateTimeFormatter = new DateTimeFormatter("fr-CA"); var aliName:String = fmt.actualLocaleIDName;

    Assuming that the operating system in the example above does not support the "fr-CA" (French-Canada) locale ID, a fallback is used. In this case the fallback locale ID is "fr-FR" (French-France).

LocaleIDrequestedLocaleIDNameDateTimeFormatter()
lastOperationStatus The status of previous operation that this DateTimeFormatter object performed.String The status of previous operation that this DateTimeFormatter object performed. The lastOperationStatus property is set whenever the constructor or a method of this class is called, or another property is set. For the possible values see the description for each method. LastOperationStatusrequestedLocaleIDName The name of the requested locale ID that was passed to the constructor of this DateTimeFormatter object.String The name of the requested locale ID that was passed to the constructor of this DateTimeFormatter object.

If the LocaleID.DEFAULT value was used then the name returned is "i-default". The actual locale used can differ from the requested locale when a fallback locale is applied. The name of the actual locale can be retrieved using the actualLocaleIDName property.

LocaleIDactualLocaleIDNameDateTimeFormatter()
LastOperationStatus The LastOperationStatus class enumerates constant values that represent the status of the most recent globalization service operation.Object The LastOperationStatus class enumerates constant values that represent the status of the most recent globalization service operation. These values can be retrieved through the read-only property lastOperationStatus available in most globalization classes. BUFFER_OVERFLOW_ERROR Indicates that given buffer is not enough to hold the result.bufferOverflowErrorString Indicates that given buffer is not enough to hold the result. ERROR_CODE_UNKNOWN Indicates that the return error code is not known.errorCodeUnknownString Indicates that the return error code is not known. Any non-static method or read/write properties can return this error when the operation is not successful and the return error code is not known. ILLEGAL_ARGUMENT_ERROR Indicates that an argument passed to a method was illegal.illegalArgumentErrorString Indicates that an argument passed to a method was illegal.

For example, the following code shows that an invalid argument error status is set when CurrencyFormatter.grouping property is set to the invalid value "3;".

var cf:CurrencyFormatter = new CurrencyFormatter("en-US"); cf.groupingPattern = "3;"; trace(cf.lastOperationStatus); // "illegalArgumentError"
INDEX_OUT_OF_BOUNDS_ERROR Indicates that an iterator went out of range or an invalid parameter was specified for month, day, or time.indexOutOfBoundsErrorString Indicates that an iterator went out of range or an invalid parameter was specified for month, day, or time. INVALID_ATTR_VALUE Indicates that a given attribute value is out of the expected range.invalidAttrValueString Indicates that a given attribute value is out of the expected range.

The following example shows that setting the NumberFormatter.negativeNumberFormat property to an out-of-range value results in an invalid attribute value status.

var nf:NumberFormatter = new NumberFormatter(LocaleID.DEFAULT); nf.negativeNumberFormat = 9; nf.lastOperationStatus; // "invalidAttrValue"
INVALID_CHAR_FOUND Indicates that invalid Unicode value was found.invalidCharFoundString Indicates that invalid Unicode value was found. MEMORY_ALLOCATION_ERROR Indicates that memory allocation has failed.memoryAllocationErrorString Indicates that memory allocation has failed. NO_ERROR Indicates that the last operation succeeded without any errors.noErrorString Indicates that the last operation succeeded without any errors. This status can be returned by all constructors, non-static methods, static methods and read/write properties. NUMBER_OVERFLOW_ERROR Indicates that an operation resulted a value that exceeds a specified numeric type.numberOverflowErrorString Indicates that an operation resulted a value that exceeds a specified numeric type. PARSE_ERROR Indicates that the parsing of a number failed.parseErrorString Indicates that the parsing of a number failed. This status can be returned by parsing methods of the formatter classes, such as CurrencyFormatter.parse() and NumberFormatter.parseNumber(). For example, if the value "12abc34" is passed as the parameter to the CurrencyFormatter.parse() method, the method returns "NaN" and sets the lastOperationStatus value to LastOperationStatus.PARSE_ERROR. PATTERN_SYNTAX_ERROR Indicates that the pattern for formatting a number, date, or time is invalid.patternSyntaxErrorString Indicates that the pattern for formatting a number, date, or time is invalid. This status is set when the user's operating system does not support the given pattern.

For example, the following code shows the value of the lastOperationStatus property after an invalid "xx" pattern is used for date formatting:

var df:DateTimeFormatter = new DateTimeFormatter("en-US"); df.setDateTimePattern("xx"); trace(df.lastOperationStatus); // "patternSyntaxError"
PLATFORM_API_FAILED Indicates that an underlying platform API failed for an operation.platformAPIFailedString Indicates that an underlying platform API failed for an operation. TRUNCATED_CHAR_FOUND Indicates that a truncated Unicode character value was found.truncatedCharFoundString Indicates that a truncated Unicode character value was found. UNEXPECTED_TOKEN Indicates that an unexpected token was detected in a Locale ID string.unexpectedTokenString Indicates that an unexpected token was detected in a Locale ID string.

For example, the following code shows the value of the lastOperationStatus property after an incomplete string is used when requesting a locale ID. As a result the lastOperationStatus property is set to the value UNEXPECTED_TOKEN after a call to the LocaleID.getKeysAndValues() method.

var locale:LocaleID = new LocaleID("en-US@Collation"); var kav:Object = locale.getKeysAndValues(); trace(locale.lastOperationStatus); // "unexpectedToken"
UNSUPPORTED_ERROR Indicates that the requested operation or option is not supported.unsupportedErrorString Indicates that the requested operation or option is not supported. This status can be returned by methods like DateTimeFormatter.setDateTimePattern() and when retrieving properties like Collator.ignoreCase. USING_DEFAULT_WARNING Indicates that an operating system default value was used during the most recent operation.usingDefaultWarningString Indicates that an operating system default value was used during the most recent operation. Class constructors can return this status. USING_FALLBACK_WARNING Indicates that a fallback value was set during the most recent operation.usingFallbackWarningString Indicates that a fallback value was set during the most recent operation. This status can be returned by constructors and methods like DateTimeFormatter.setDateTimeStyles(), and when retrieving properties like CurrencyFormatter.groupingPattern.
NationalDigitsType The NationalDigitsType class enumerates constants that indicate digit sets used by the NumberFormatter class.Object The NationalDigitsType class enumerates constants that indicate digit sets used by the NumberFormatter class. The value of each constant represents the Unicode value for the zero digit in the specified decimal digit set. ARABIC_INDIC Represents the Unicode value for the zero digit of the Arabic-Indic digit set.0x0660uint Represents the Unicode value for the zero digit of the Arabic-Indic digit set. BALINESE Represents the Unicode value for the zero digit of the Balinese digit set.0x1B50uint Represents the Unicode value for the zero digit of the Balinese digit set. BENGALI Represents the Unicode value for the zero digit of the Bengali digit set.0x09E6uint Represents the Unicode value for the zero digit of the Bengali digit set. CHAM Represents the Unicode value for the zero digit of the Cham digit set.0xAA50uint Represents the Unicode value for the zero digit of the Cham digit set. DEVANAGARI Represents the Unicode value for the zero digit of the Devanagari digit set.0x0966uint Represents the Unicode value for the zero digit of the Devanagari digit set. EUROPEAN Represents the Unicode value for the zero digit of the Latin-1 (European) digit set.0x0030uint Represents the Unicode value for the zero digit of the Latin-1 (European) digit set. EXTENDED_ARABIC_INDIC Represents the Unicode value for the zero digit of the Extended Arabic-Indic digit set.0x06F0uint Represents the Unicode value for the zero digit of the Extended Arabic-Indic digit set. FULL_WIDTH Represents the Unicode value for the zero digit of the Fullwidth digit set.0xFF10uint Represents the Unicode value for the zero digit of the Fullwidth digit set. GUJARATI Represents the Unicode value for the zero digit of the Gujarati digit set.0x0AE6uint Represents the Unicode value for the zero digit of the Gujarati digit set. GURMUKHI Represents the Unicode value for the zero digit of the Gurmukhi digit set.0x0A66uint Represents the Unicode value for the zero digit of the Gurmukhi digit set. KANNADA Represents the Unicode value for the zero digit of the Kannada digit set.0x0CE6uint Represents the Unicode value for the zero digit of the Kannada digit set. KAYAH_LI Represents the Unicode value for the zero digit of the Kayah Li digit set.0xA900uint Represents the Unicode value for the zero digit of the Kayah Li digit set. KHMER Represents the Unicode value for the zero digit of the Khmer digit set.0x17E0uint Represents the Unicode value for the zero digit of the Khmer digit set. LAO Represents the Unicode value for the zero digit of the Lao digit set.0x0ED0uint Represents the Unicode value for the zero digit of the Lao digit set. LEPCHA Represents the Unicode value for the zero digit of the Lepcha digit set.0x1C40uint Represents the Unicode value for the zero digit of the Lepcha digit set. LIMBU Represents the Unicode value for the zero digit of the Limbu digit set.0x1946uint Represents the Unicode value for the zero digit of the Limbu digit set. MALAYALAM Represents the Unicode value for the zero digit of the Malayalam digit set.0x0D66uint Represents the Unicode value for the zero digit of the Malayalam digit set. MONGOLIAN Represents the Unicode value for the zero digit of the Mongolian digit set.0x1810uint Represents the Unicode value for the zero digit of the Mongolian digit set. MYANMAR_SHAN Represents the Unicode value for the zero digit of the Myanmar Shan digit set.0x1090uint Represents the Unicode value for the zero digit of the Myanmar Shan digit set. MYANMAR Represents the Unicode value for the zero digit of the Myanmar digit set.0x1040uint Represents the Unicode value for the zero digit of the Myanmar digit set. NEW_TAI_LUE Represents the Unicode value for the zero digit of the New Tai Lue digit set.0x19D0uint Represents the Unicode value for the zero digit of the New Tai Lue digit set. NKO Represents the Unicode value for the zero digit of the Nko digit set.0x07C0uint Represents the Unicode value for the zero digit of the Nko digit set. OL_CHIKI Represents the Unicode value for the zero digit of the Ol Chiki digit set.0x1C50uint Represents the Unicode value for the zero digit of the Ol Chiki digit set. ORIYA Represents the Unicode value for the zero digit of the Oriya digit set.0x0B66uint Represents the Unicode value for the zero digit of the Oriya digit set. OSMANYA Represents the Unicode value for the zero digit of the Osmanya digit set.0x104A0uint Represents the Unicode value for the zero digit of the Osmanya digit set. SAURASHTRA Represents the Unicode value for the zero digit of the Saurashtra digit set.0xA8D0uint Represents the Unicode value for the zero digit of the Saurashtra digit set. SUNDANESE Represents the Unicode value for the zero digit of the Sundanese digit set.0x1BB0uint Represents the Unicode value for the zero digit of the Sundanese digit set. TAMIL Represents the Unicode value for the zero digit of the Tamil digit set.0x0BE6uint Represents the Unicode value for the zero digit of the Tamil digit set. TELUGU Represents the Unicode value for the zero digit of the Telugu digit set.0x0C66uint Represents the Unicode value for the zero digit of the Telugu digit set. THAI Represents the Unicode value for the zero digit of the Thai digit set.0x0E50uint Represents the Unicode value for the zero digit of the Thai digit set. TIBETAN Represents the Unicode value for the zero digit of the Tibetan digit set.0x0F20uint Represents the Unicode value for the zero digit of the Tibetan digit set. VAI Represents the Unicode value for the zero digit of the Vai digit set.0xA620uint Represents the Unicode value for the zero digit of the Vai digit set. CurrencyParseResult A data structure that represents a currency amount and currency symbol or string that were extracted by parsing a currency value.Object A data structure that represents a currency amount and currency symbol or string that were extracted by parsing a currency value. CurrencyFormatter.parse()CurrencyParseResult Constructs a currency parse result object.valueNumberunknownA number representing the currency amount value. symbolStringA string representing the currency symbol. Constructs a currency parse result object. currencyString The portion of the input string that corresponds to the currency symbol or currency string.String The portion of the input string that corresponds to the currency symbol or currency string. value The currency amount value that was extracted from the input string.Number The currency amount value that was extracted from the input string. NumberParseResult A data structure that holds information about a number that was extracted by parsing a string.Object A data structure that holds information about a number that was extracted by parsing a string.

The number string can contain a prefix and suffix surrounding a number. In such cases the startIndex property is set to the first character of the number. Also, the endIndex property is set to the index of the character that follows the last character of the number.

NumberFormatter.parse()NumberFormatter.parseNumber()NumberParseResult Constructs a number parse result object.valueNumberunknownThe value of the numeric portion of the input string. startIndexint0x7fffffffThe index of the first character of the number in the input string. endIndexint0x7fffffffThe index of the character after the last character of the number in the input string. Constructs a number parse result object. NumberParseResult objects are usually created by the NumberFormatter.parse() and NumberFormatter.parseNumber() methods, rather than by calling this constructor directly. NumberFormatter.parse()NumberFormatter.parseNumber()endIndex The index of the character after the last character of the numeric portion of the input string.int The index of the character after the last character of the numeric portion of the input string. startIndex The index of the first character of the numeric portion of the input string.int The index of the first character of the numeric portion of the input string. value The value of the numeric portion of the input string.Number The value of the numeric portion of the input string.
LocaleID The LocaleID class provides methods for parsing and using locale ID names.Object The LocaleID class provides methods for parsing and using locale ID names. This class supports locale ID names that use the syntax defined by the Unicode Technical Standard #35 (http://unicode.org/reports/tr35/). The following example shows how to retrieve and display information about LocaleID strings for different locales.

This example uses the following locales: Arabic (Saudi Arabia), English (US), English (US, POSIX variant), Chinese (PRC), Chinese (Taiwan), Chinese (Simplified Han Script), Chinese (PRC with several keys and values)

The example does the following for each locale in the list:

  1. Creates a new LocaleID object.
  2. Displays various properties of the LocaleID. The values shown will differ based on your operating system and user preferences.
  3. Displays the full set of keys and values for the LocaleID.
package { import flash.display.Sprite; import flash.globalization.LocaleID; public class LocaleIDExample extends Sprite { public function LocaleIDExample() { var localeNames:Array = ["ar-SA", "EN_us", "en-US-POSIX", "zh-CH", "zh-TW", "zh-Hans", "zh-CH@collation=pinyin;calendar=chinese;currency=RMB"]; for ( var i:int = 0; i < localeNames.length; i++ ) { var locID:LocaleID = new LocaleID( localeNames[i] as String ); trace('\n\n' + "LocaleID requested: " + locID.requestedLocaleIDName + "; actual: " + locID.actualLocaleIDName); trace( "Last Operation Status after new LocaleID: " + locID.lastOperationStatus); trace("name: " + locID.name); trace("language: " + locID.getLanguage() + "; status: " + locID.lastOperationStatus); trace("script: " + locID.getScript() + "; status: " + locID.lastOperationStatus); trace("region: " + locID.getRegion() + "; status: " + locID.lastOperationStatus); trace("variant: " + locID.getVariant() + "; status: " + locID.lastOperationStatus); trace("isRightToLeft: ", locID.isRightToLeft(), "; status: " + locID.lastOperationStatus); var keysAndValues:Object = locID.getKeysAndValues(); var key:String; for (key in keysAndValues) { trace("key: ", key + " value: " + keysAndValues[ key ]); } trace( "Last Operation Status after getKeysAndValues(): " + locID.lastOperationStatus); } } } }
Unicode Technical Standard #35LocaleID Constructs a new LocaleID object, given a locale name.if the name is null. ArgumentErrorArgumentErrornameStringA locale ID name, which can also include an optional collation string. For example: "en-US" or "de-DE@collation=phonebook" Constructs a new LocaleID object, given a locale name. The locale name must conform to the syntax defined by the Unicode Technical Standard #35 (http://unicode.org/reports/tr35/).

When the constructor completes successfully the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

When the requested locale ID name is not available then the lastOperationStatus is set to one of the following:

  • LastOperationStatus.USING_FALLBACK_WARNING
  • LastOperationStatus.USING_DEFAULT_WARNING

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

For details on the warnings listed above and other possible values of the lastOperationStatus property see the descriptions in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
determinePreferredLocales Returns a list of acceptable locales based on a list of desired locales and a list of the locales that are currently available.A subset of the available locales, sorted according to the user's preferences. wantA list of the user's preferred locales sorted in order of preference. haveA list of locales available to the application. The order of this list is not important. keywordStringuserinterfaceA keyword to use to help determine the best fit. Returns a list of acceptable locales based on a list of desired locales and a list of the locales that are currently available.

The resulting list is sorted according in order of preference.

Here is a typical use case for this method:

  • A user specifies a list of languages that she understands (stored in a user profile, a browser setting, or a cookie). The user lists the languages that she understands best first, so the order of the languages in the list is relevant. This list is the "want" list.
  • The application is localized into a number of different languages. This list is the "have" list.
  • The determinePreferredLocales() method returns an intersection of the two lists, sorted so that the user's preferred languages come first.

If this feature is not supported on the current operating system, this method returns a null value.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
getKeysAndValues Returns an object containing all of the key and value pairs from the LocaleID object.An Object containing all the keys and values in the LocaleID object, structured as an associative array or hashtable. Object Returns an object containing all of the key and value pairs from the LocaleID object.

The returned object is structured as a hash table or associative array, where each property name represents a key and the value of the property is value for that key. For example, the following code lists all of the keys and values obtained from the LocaleID object using the getKeysAndValues() method:

var myLocale:LocaleID = new LocaleID("fr-CA"); var localeData:Object = myLocale.getKeysAndValues(); for (var propertyName:String in localeData) { trace(propertyName + " = " + localeData[propertyName]); }

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
getLanguage Returns the language code specified by the locale ID name.A two-character language code obtained by parsing the locale ID name. String Returns the language code specified by the locale ID name.

If the locale name cannot be properly parsed then the language code is the same as the full locale name.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
getRegion Returns the region code specified by the locale ID name.A two-character region code, or an empty string if the region code cannot be parsed or otherwise determined from the locale name. String Returns the region code specified by the locale ID name.

This method returns an empty string if the region code cannot be parsed or guessed This could occur if an unknown or incomplete locale ID name like "xy" is used. The region code is not validated against a fixed list. For example, the region code returned for a locale ID name of "xx-YY" is "YY".

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

If the region is not part of the specified locale name, the most likely region code for the locale is "guessed" and lastOperationStatus property is set to LastOperationStatus.USING_FALLBACK_WARNING

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
getScript Returns the script code specified by the locale ID name.A four-character script code, or an empty string if the script code cannot be parsed or otherwise determined from the locale name. String Returns the script code specified by the locale ID name.

This method returns an empty string if the script code cannot be parsed or guessed This could occur if an unknown or incomplete locale ID name like "xy" is used. The script code is not validated against a fixed list. For example, the script code returned for a locale ID name of "xx-Abcd-YY" is "Abcd".

The region, as well as the language, can also affect the return value. For example, the script code for "mn-MN" (Mongolian-Mongolia) is "Cyrl" (Cyrillic), while the script code for "mn-CN" (Mongolian-China) is "Mong" (Mongolian).

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

If the script code is not part of the specified locale name, the most likely script code is "guessed" and lastOperationStatus property is set to LastOperationStatus.USING_FALLBACK_WARNING.

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
getVariant Returns the language variant code specified by the locale ID name.A language variant code, or an empty string if the locale ID name does not contain a language variant code. String Returns the language variant code specified by the locale ID name.

This method returns an empty string if there is no language variant code in the given locale ID name. (No guessing is necessary because few locales have or need a language variant.)

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
isRightToLeft Specifies whtehr the text direction for the specified locale is right to left.true if the general text flows in a line of text should go from right to left; otherwise false; Boolean Specifies whtehr the text direction for the specified locale is right to left.

The result can be used to determine the direction of the text in the Flash text engine, and to decide whether to mirror the user interface to support the current text direction.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

flashx.textLayout.formats.DirectionlastOperationStatusLastOperationStatus
DEFAULT Indicates that the user's default linguistic preferences should be used, as specified in the user's operating system settings.i-defaultString Indicates that the user's default linguistic preferences should be used, as specified in the user's operating system settings. For example, such preferences are typically set using the "Control Panel" for Windows, or the "System Preferences" in Mac OS X.

Using the LocaleID.DEFAULT setting can result in the use of a different locale ID name for different kinds of operations. For example, one locale could be used for sorting and a different one for formatting. This flexibility respects the user preferences, and the class behaves this way by design.

This locale identifier is not always the most appropriate one to use. For applications running in the browser, the browser's preferred locale could be a better choice. It is often a good idea to let the user alter the preferred locale ID name setting and preserve that preference in a user profile, cookie, or shared object.

lastOperationStatus The status of the most recent operation that this LocaleID object performed.String The status of the most recent operation that this LocaleID object performed. The lastOperationStatus property is set whenever the constructor or a method of this class is called or another property is set. For the possible values see the description for each method. LastOperationStatusname Returns a slightly more "canonical" locale identifier.String Returns a slightly more "canonical" locale identifier.

This method performs the following conversion to the locale ID name to give it a more canonical form.

  • Proper casing is applied to all of the components.
  • Underscores are converted to dashes.

No additional processing is performed. For example, aliases are not replaced, and no elements are added or removed.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

DateTimeStyle Enumerates constants that determine a locale-specific date and time formatting pattern.Object Enumerates constants that determine a locale-specific date and time formatting pattern. These constants are used when constructing a DateTimeFormatter object or when calling the DateTimeFormatter.setDateTimeStyles() method.

The CUSTOM constant cannot be used in the DateTimeFormatter constructor or the DateFormatter.setDateTimeStyles() method. This constant is instead set as the timeStyle and dateStyle property as a side effect of calling the DateTimeFormatter.setDateTimePattern() method.

DateTimeFormatterCUSTOM Specifies that a custom pattern string is used to specify the date or time style.customString Specifies that a custom pattern string is used to specify the date or time style. LONG Specifies the long style of a date or time.longString Specifies the long style of a date or time. MEDIUM Specifies the medium style of a date or time.mediumString Specifies the medium style of a date or time. NONE Specifies that the date or time should not be included in the formatted string.noneString Specifies that the date or time should not be included in the formatted string. SHORT Specifies the short style of a date or time.shortString Specifies the short style of a date or time.
StringTools The StringTools class provides locale-sensitive case conversion methods.Object The StringTools class provides locale-sensitive case conversion methods.

In some situations the conversion between uppercase and lowercase letters is not a simple mapping from one character to another and instead requires language- or context-specific processing. For example:

  • In Turkish and Azeri, the uppercase of the dotted lowercase i is an uppercase dotted İ (U+0130). Similarly the lowercase of a dotless uppercase I, is a lowercase dotless ı (U+0131).
  • The lowercase sharp S, ß (U+00DF), used in German is converted to uppercase double SS.
  • In Greek there are two representations of the lowercase sigma, σ (U+03C3) and ς (U+03C2), which both convert to the single uppercase sigma Σ (U+03A3).

The toLowerCase() and toUpperCase() methods of this class provide this special case conversion logic.

Due to the use of the user's settings, the use of case conversion rules provided by the operating system, and the use of a fallback locale when a requested locale is not supported, different users can see different case conversion results even when using the same locale ID.

This example shows how different strings are converted to lower case and upper case in a lingustically correct manner.

This example takes the following steps:

  1. Creates a StringTools object.
  2. Defines three strings with characters unique to the Turkish, Greek, and German languages.
  3. Converts each string to upper case and lower case and displays the results. This example demonstrates interesting locale-specific behavior for characters like the Turkish "ı" and "İ", the German "ß" and the Greek "Σςσ".
package { import flash.display.Sprite; import flash.globalization.LocaleID; import flash.globalization.StringTools; import flash.text.TextField; import flash.text.TextFieldAutoSize; public class StringToolsExample extends Sprite { public function StringToolsExample() { var localeName:String= LocaleID.DEFAULT; var strTool:StringTools = new StringTools(localeName); trace('\n\n' + "LocaleID requested: " + nf.requestedLocaleIDName + "; actual: " + nf.actualLocaleIDName); trace( "Last Operation Status:" + nf.lastOperationStatus ); var turkishStr:String = "iI ıİ"; var greekStr:String = "Σςσβΰ�Σ"; var germanStr:String= "ß"; var tfTurInp:TextField = createTextField(10, 10); tfTurInp.text="Turkish Input: \t " + turkishStr; var tfdash:TextField = createTextField(10, 20); tfdash.text="-------------------"; var tf1:TextField = createTextField(10, 30); tf1.text="\t Upper case: \t " + strTool.toUpperCase(turkishStr); var tf2:TextField = createTextField(10, 40); tf2.text="\t Lower case: \t " + strTool.toLowerCase(turkishStr); var tfgreekInp:TextField = createTextField(10, 60); tfgreekInp.text="Greek Input: \t " + greekStr; var tfdash1:TextField = createTextField(10, 70); tfdash1.text="-------------------"; var tf3:TextField = createTextField(10, 80); tf3.text="\t Upper case: \t " + strTool.toUpperCase(greekStr); var tf4:TextField = createTextField(10, 90); tf4.text="\t Lower case: \t " + strTool.toLowerCase(greekStr); var tfgermanInp:TextField = createTextField(10, 110); tfgermanInp.text="German Input: \t " + germanStr; var tfdash2:TextField = createTextField(10, 120); tfdash2.text="-------------------"; var tf5:TextField = createTextField(10, 130); tf5.text="\t Upper case: \t " + strTool.toUpperCase(germanStr); var tf6:TextField = createTextField(10, 140); tf6.text="\t Lower case: \t " + strTool.toLowerCase(germanStr); } private function createTextField(x:Number, y:Number):TextField { var result:TextField = new TextField(); result.x = x; result.y = y; result.autoSize=TextFieldAutoSize.LEFT; addChild(result); return result; } } }
StringTools Constructs a new StringTools object that provides case conversion and other utilities according to the conventions of a given locale.when the requestedLocaleIDName parameter is null ArgumentErrorArgumentErrorrequestedLocaleIDNameStringThe preferred locale ID name to use when determining date or time formats. Constructs a new StringTools object that provides case conversion and other utilities according to the conventions of a given locale.

This constructor determines if the current operating system supports the requested locale ID name. If it is not supported then a fallback locale is used instead. If a fallback locale is used then the lastOperationStatus property indicates the type of fallback, and the actualLocaleIDName property contains the name of the fallback locale ID.

When this constructor completes successfully the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

When the requested locale ID name is not available then the lastOperationStatus is set to one of the following:

  • LastOperationStatus.USING_FALLBACK_WARNING
  • LastOperationStatus.USING_DEFAULT_WARNING

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

LocaleIDlastOperationStatusrequestedLocaleIDNameactualLocaleIDName
getAvailableLocaleIDNames Lists all of the locale ID names supported by this class.A vector of strings containing all of the locale ID names supported by this class. Lists all of the locale ID names supported by this class.

If this class is not supported on the current operating system, this method returns a null value.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

toLowerCase Converts a string to lowercase according to language conventions.when the s parameter is null. ArgumentErrorArgumentErrorThe converted lowercase string. StringsStringA string to convert to lowercase. Converts a string to lowercase according to language conventions. Depending on the locale, the output string length can differ from the input string length.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
toUpperCase Converts a string to uppercase according to language conventions.when the s parameter is null. ArgumentErrorArgumentErrorThe converted uppercase string. StringsStringA string to convert to uppercase. Converts a string to uppercase according to language conventions. Depending on the locale, the output string length can differ from the input string length.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
actualLocaleIDName The name of the actual locale ID used by this StringTools object.String The name of the actual locale ID used by this StringTools object.

There are three possibilities for the value of the name, depending on operating system and the value of the requestedLocaleIDName parameter passed to the StringTools() constructor.

  1. If the requested locale was not LocaleID.DEFAULT and the operating system provides support for the requested locale, then the name returned is the same as the requestedLocaleIDName property.
  2. If LocaleID.DEFAULT was used as the value for the requestedLocaleIDName parameter to the constructor, then the name of the current locale specified by the user's operating system is used. The LocaleID.DEFAULT value preserves user's customized setting in the OS. Passing an explicit value as the requestedLocaleIDName parameter does not necessarily give the same result as using the LocaleID.DEFAULT even if the two locale ID names are the same. The user could have customized the locale settings on the machine, and by requesting an explicit locale ID name rather than using LocaleID.DEFAULT your application would not retrieve those customized settings.

    For example:

    var tools:StringTools = new StringTools(LocaleID.DEFAULT); var aliName:String = tools.actualLocaleIDName;

    In the above example, aliName is the name of the locale corresponding to the user's current operating systems settings (e.g. "it-IT" if the user's locale is set to Italian-Italy), and not "i-default" (the name of the LocaleID.DEFAULT locale).

  3. If the system does not support the requestedLocaleIDName specified in the constructor then a fallback locale ID name is provided.

    For Example:

    var tools:StringTools = new StringTools("fr-CA"); var aliName:String = tools.actualLocaleIDName;

    Assuming that the operating system in the example above does not support the "fr-CA" (French-Canada) locale ID, a fallback is used. In this case the fallback locale ID is "fr-FR" (French-France).

LocaleIDrequestedLocaleIDNameStringTools
lastOperationStatus The status of the most recent operation that this StringTools object performed.String The status of the most recent operation that this StringTools object performed. The lastOperationStatus property is set whenever the constructor or a method of this class is called or another property is set. For the possible values see the description for each method. LastOperationStatusrequestedLocaleIDName The name of the requested locale ID that was passed to the constructor of this StringTools object.String The name of the requested locale ID that was passed to the constructor of this StringTools object.

If the LocaleID.DEFAULT value was used then the name returned is "i-default". The actual locale used can differ from the requested locale when a fallback locale is applied. The name of the actual locale can be retrieved using the actualLocaleIDName property.

LocaleIDactualLocaleIDNameStringTools()
CollatorMode The CollatorMode class enumerates constant values that govern the behavior of string comparisons performed by a Collator object.Object The CollatorMode class enumerates constant values that govern the behavior of string comparisons performed by a Collator object. These constants represent the values that can be passed in the initialMode parameter of the Collator() constructor. CollatorMATCHING Initializes a Collator object so that the compare method is optimized for determining whether two strings are equivalent.matchingString Initializes a Collator object so that the compare method is optimized for determining whether two strings are equivalent. In this mode, string comparisons ignore differences in uppercase and lower case letters, accented characters, etc. Collator() constructorSORTING Initializes a Collator object so that the compare method is optimized for sorting a list of text strings to be displayed to an end user.sortingString Initializes a Collator object so that the compare method is optimized for sorting a list of text strings to be displayed to an end user. In this mode, string comparisons consider differences in uppercase and lowercase letters, accented characters, and so on, according to the language and sorting rules required by the locale. Collator() constructorNumberFormatter The NumberFormatter class provides locale-sensitive formatting and parsing of numeric values.Object The NumberFormatter class provides locale-sensitive formatting and parsing of numeric values. It can format int, uint, and Number objects.

The NumberFormatter class uses the data and functionality provided by the operating system and is designed to format numbers according to the conventions of a specific locale, based on the user's preferences and features supported by the user's operating system. The position of the negative symbol, the decimal separator, the grouping separator, the grouping pattern, and other elements within the number format can vary depending on the locale.

If the operating system supports the requested locale, the number formatting properties are set according to the conventions and defaults of the requested locale. If the requested locale is not available, then the properties are set according to a fallback or default system locale, which can be retrieved using the actualLocaleIDName property.

Due to the use of the user's settings, the use of formatting patterns provided by the operating system, and the use of a fallback locale when a requested locale is not supported, different users can see different formatting results, even when using the same locale ID.

This example shows how numbers can be formatted differently across different locales.

This example uses the following locales: default operating system locale for number formatting, Japanese (Japan), English (US), and French (France). The example uses the static member LocaleID.DEFAULT to request the default operating system locale.

The results from this example might differ based on your operating system and user preferences.

This example does the following for each locale in the list:

  1. Creates a NumberFormatter object.
  2. Formats the same value as a Number, an integer, and an unsigned integer, and displays the results.
package { import flash.globalization.NumberFormatter; import flash.globalization.LocaleID; public class NumberFormatterExample extends Sprite { public function NumberFormatterExample():void { var localeNames:Array = [LocaleID.DEFAULT,"ja_JP","en_US","fr_FR"]; for ( var i:int = 0; i < localeNames.length; i++ ) { var nf:NumberFormatter = new NumberFormatter( localeNames[i] as String ); trace('\n\n' + "LocaleID requested: " + nf.requestedLocaleIDName + "; actual: " + nf.actualLocaleIDName); trace( "Last Operation Status:" + nf.lastOperationStatus ); var numberString:String = nf.formatNumber(123456789.19); trace( "Formatted Number:" + numberString); numberString = nf.formatInt(-123456789); trace( "Formatted Int:" + numberString); numberString = nf.formatUint(123456789); trace( "Formatted UInt:" + numberString); } } } }
This example shows two different ways to parse an input string and extract a numeric value.

The results from this example might differ based on your operating system and user preferences.

This example does the following:

  1. Creates a NumberFormatter object.
  2. Calls the NumberFormatter.parse() method to parse the string and return a NumberParseResult object.
  3. Calls the NumberFormatter.parseNumber() method to parse the string and return a Number value.
package { import flash.globalization.NumberFormatter; import flash.globalization.NumberParseResult; import flash.globalization.LastOperationStatus; import flash.globalization.LocaleID; public class NumberFormatterParseExample { public function NumberFormatterParseExample():void { var nf:NumberFormatter = new NumberFormatter( "en_US" ); trace("LocaleID requested: " + nf.requestedLocaleIDName + "; actual: " + nf.actualLocaleIDName); trace( "Last Operation Status:" + nf.lastOperationStatus ); var inputNumberString:String = "123,567,89,0.254"; var parseResult:NumberParseResult = nf.parse(inputNumberString); if ( nf.lastOperationStatus == LastOperationStatus.NO_ERROR ) { trace("Parsed value:" + parseResult.value); } inputNumberString = "-123,567,89,0.254"; var parsedNumber:Number = nf.parseNumber(inputNumberString); if ( nf.lastOperationStatus == LastOperationStatus.NO_ERROR ) { trace("Parsed value:" + parsedNumber); } } } }
NumberFormatter Constructs a new NumberFormatter object to format numbers according to the conventions of a given locale.if the requestedLocaleIDName is null TypeErrorTypeErrorrequestedLocaleIDNameStringThe preferred locale ID name to use when determining number formats. Constructs a new NumberFormatter object to format numbers according to the conventions of a given locale.

This constructor determines if the current operating system supports the requested locale ID name. If it is not supported then a fallback locale is used instead. If a fallback locale is used then the the lastOperationStatus property indicates the type of fallback, and the actualLocaleIDName property contains the name of the fallback locale ID.

To format based on the user's current operating system preferences, pass the value LocaleID.DEFAULT in the requestedLocaleIDName parameter to the constructor.

When the constructor completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

When the requested locale ID name is not available then the lastOperationStatus is set to one of the following:

  • LastOperationStatus.USING_FALLBACK_WARNING
  • LastOperationStatus.USING_DEFAULT_WARNING

If this class is not supported on the current operating system, then the lastOperationStatus property is set to:

  • LastOperationStatus.UNSUPPORTED_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

For details on the warnings listed above and other possible values of the lastOperationStatus property see the descriptions in the LastOperationStatus class.

LocaleIDrequestedLocaleIDNameactualLocaleIDNamelastOperationStatusLastOperationStatus
formatInt Formats an int value.for any internal memory allocation problems. MemoryErrorflash.errors:MemoryErrorA formatted number string. StringvalueintAn int value to format. Formats an int value. This function is equivalent to the formatNumber() method except that it takes an int value. If the value passed in is too large or small, such as a value greater than 1.72e308 or less than 1.72e-308, then this function returns 0.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusflash.globalization.LastOperationStatus
formatNumber Formats a Number value.if there are any internal memory allocation problems. MemoryErrorflash.errors:MemoryErrorA formatted number string. StringvalueNumberA Number value to format. Formats a Number value.

This function formats the number based on the property values of the formatter. If the properties are not modified after the the numberFormatter object is created, the numbers are formatted according to the locale specific conventions provided by the operating system for the locale identified by actualLocaleIDName. To customize the format, the properties can be altered to control specific aspects of formatting a number.

Very large numbers and very small magnitude numbers can be formatted with this function. However, the number of significant digits is limited to the precision provided by the Number object. Scientific notation is not supported.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
formatUint Formats a uint value.if there are any internal memory allocation problems. MemoryErrorflash.errors:MemoryErrorA formatted number string. StringvalueuintA uint value. Formats a uint value. This function is equivalent to the formatNumber() method except that it takes a uint. If the value passed in is too large, such as a value greater than 1.72e308, then this function returns 0.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatus
getAvailableLocaleIDNames Lists all of the locale ID names supported by this class.A vector of strings containing all of the locale ID names supported by this class. Lists all of the locale ID names supported by this class.

If this class is not supported on the current operating system, this method returns a null value.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

parseNumber Parses a string that contains only digits and optional whitespace characters and returns a Number.if the parseString is null TypeErrorTypeErrorNumberparseStringString Parses a string that contains only digits and optional whitespace characters and returns a Number. If the string does not begin with a number or contains characters other than whitespace that are not part of the number, then this method returns NaN. White space before or after the numeric digits is ignored. A white space character is a character that has a Space Separator (Zs) property in the Unicode Character Database (see http://www.unicode.org/ucd/).

If the numeric digit is preceded or followed by a plus sign '+' it is treated as a non-whitespace character. The return value is NaN.

See the description of the parse function for more information about number parsing and what constitutes a valid number.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatusparse()parseFloat()NationalDigitsType
parse Parses a string and returns a NumberParseResult object containing the parsed elements.if the parseString is null TypeErrorTypeErrorflash.globalization:NumberParseResultparseStringString Parses a string and returns a NumberParseResult object containing the parsed elements.

The NumberParseResult object contains the value of the first number found in the input string, the starting index for the number within the string, and the index of the first character after the number in the string.

If the string does not contain a number, the value property of the NumberParseResult is set to NaN and the startIndex and endIndex properties are set to the hexadecimal value 0x7fffffff.

This function uses the value of the decimalSeparator property to determine the portion of the number that contains fractional digits, and the groupingSeparator property to determine which characters are allowed within the digits of a number, and the negativeNumberFormat property to control how negative values are represented.

The following table identifies the result of strings parsed for the various NegativeNumberFormat values:

NegativeNumberFormatInput StringResult(n)"(123)" or "( 123 )""-123"-n"-123" or "- 123""-123"- n"-123" or "- 123""-123"n-"123-" or "123 -""-123"n -"123-" or "123 -""-123"

A single white space is allowed between the number and the minus sign or parenthesis.

Other properties are ignored when determining a valid number. Specifically the value of the digitsType property is ignored and the digits can be from any of the digit sets that are enumerated in the NationalDigitsType class. The values of the groupingPattern and useGrouping properties do not influence the parsing of the number.

If numbers are preceded or followed in the string by a plus sign '+', the plus sign is treated as a character that is not part of the number.

This function does not parse strings containing numbers in scientific notation (e.g. 1.23e40).

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

The following code parses a number from a string and retrieves the prefix and suffix: var nf:NumberFormatter = new NumberFormatter("fr-FR"); var str:String = "1,56 mètre" var result:NumberParseResult = nf.parse(str); trace(result.value) // 1.56 trace(str.substr(0,result.startIndex)); // "" trace(str.substr(result.startIndex, result.endIndex)); // "1,56" trace(str.substr(result.endIndex)); // " mètre"
lastOperationStatusLastOperationStatusNumberParseResultparseNumber()parseFloat()NationalDigitsType
actualLocaleIDName The name of the actual locale ID used by this NumberFormatter object.String The name of the actual locale ID used by this NumberFormatter object.

There are three possibilities for the value of the name, depending on operating system and the value of the requestedLocaleIDName parameter passed to the Collator() constructor.

  1. If the requested locale was not LocaleID.DEFAULT and the operating system provides support for the requested locale, then the name returned is the same as the requestedLocaleIDName property.
  2. If LocaleID.DEFAULT was used as the value for the requestedLocaleIDName parameter to the constructor, then the name of the current locale specified by the user's operating system is used. The LocaleID.DEFAULT value preserves user's customized setting in the OS. Passing an explicit value as the requestedLocaleIDName parameter does not necessarily give the same result as using the LocaleID.DEFAULT even if the two locale ID names are the same. The user could have customized the locale settings on their machine, and by requesting an explicit locale ID name rather than using LocaleID.DEFAULT your application would not retrieve those customized settings.

    For example:

    var fmt:NumberFormatter = new NumberFormatter(LocaleID.DEFAULT); var aliName:String = fmt.actualLocaleIDName;

    In the above example, aliName is the name of the locale corresponding to the user's current operating systems settings (e.g. "it-IT" if the user's locale is set to Italian-Italy), and not "i-default" (the name of the LocaleID.DEFAULT locale).

  3. If the system does not support the requestedLocaleIDName specified in the constructor then a fallback locale ID name is provided.

    For Example:

    var fmt:NumberFormatter = new NumberFormatter("fr-CA"); var aliName:String = fmt.actualLocaleIDName;

    Assuming that the operating system in the example above does not support the "fr-CA" (French-Canada) locale ID, a fallback is used. In this case the fallback locale ID is "fr-FR" (French-France).

LocaleIDrequestedLocaleIDNameNumberFormatter()
decimalSeparator The decimal separator character used for formatting or parsing numbers that have a decimal part.Stringif this property is assigned a null value. TypeErrorTypeErrordependent on the locale and operating system. The decimal separator character used for formatting or parsing numbers that have a decimal part.

This property is initially set based on the locale that is selected when the formatter object is constructed.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

formatInt()formatNumber()formatUInt()lastOperationStatusLastOperationStatus
digitsType Defines the set of digit characters to be used when formatting numbers.uintif this property is assigned a null value. TypeErrorTypeErrordependent on the locale and operating system. Defines the set of digit characters to be used when formatting numbers.

Different languages and regions use different sets of characters to represent the digits 0 through 9. This property defines the set of digits to be used.

The value of this property represents the Unicode value for the zero digit of a decimal digit set. The valid values for this property are defined in the NationalDigitsType class.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatusNationalDigitsType
fractionalDigits The maximum number of digits that can appear after the decimal separator.int0 The maximum number of digits that can appear after the decimal separator.

Numbers are rounded to the number of digits specified by this property. The rounding scheme varies depending on the user's operating system.

When the trailingZeros property is set to true, the fractional portion of the number (after the decimal point) is padded with trailing zeros until its length matches the value of this fractionalDigits property.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

trailingZeroslastOperationStatusflash.globalization.LastOperationStatus
groupingPattern Describes the placement of grouping separators within the formatted number string.Stringif this property is assigned a null value. TypeErrorTypeError Describes the placement of grouping separators within the formatted number string.

When the useGrouping property is set to true, the groupingPattern property is used to define the placement and pattern used for the grouping separator.

The grouping pattern is defined as a string containing numbers separated by semicolons and optionally may end with an asterisk. For example: "3;2;*". Each number in the string represents the number of digits in a group. The grouping separator is placed before each group of digits. An asterisk at the end of the string indicates that groups with that number of digits should be repeated for the rest of the formatted string. If there is no asterisk then there are no additional groups or separators for the rest of the formatted string.

The first number in the string corresponds to the first group of digits to the left of the decimal separator. Subsequent numbers define the number of digits in subsequent groups to the left. Thus the string "3;2;*" indicates that a grouping separator is placed after the first group of 3 digits, followed by groups of 2 digits. For example: 98,76,54,321

The following table shows examples of formatting the number 123456789.12 with various grouping patterns. The grouping separator is a comma and the decimal separator is a period.

Grouping PatternSample Format3;*123,456,789.123;2;*12,34,56,789.123123456,789.12

Only a limited number of grouping sizes can be defined. On some operating systems, grouping patterns can only contain two numbers plus an asterisk. Other operating systems can support up to four numbers and an asterisk. For patterns without an asterisk, some operating systems only support one number while others support up to three numbers. If the maximum number of grouping pattern elements is exceeded, then additional elements are ignored and the lastOperationStatus property is set as described below.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

groupingSeparatoruseGroupinglastOperationStatusLastOperationStatus
groupingSeparator The character or string used for the grouping separator.Stringif this property is assigned a null value. TypeErrorTypeErrordependent on the locale and operating system. The character or string used for the grouping separator.

The value of this property is used as the grouping separator when formatting numbers with the useGrouping property set to true. This property is initially set based on the locale that is selected when the formatter object is constructed.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

formatInt()formatNumber()formatUInt()useGroupinglastOperationStatusLastOperationStatus
lastOperationStatus The status of previous operation that this NumberFormatter object performed.String The status of previous operation that this NumberFormatter object performed. The lastOperationStatus property is set whenever the constructor or a method of this class is called, or another property is set. For the possible values see the description for each method. LastOperationStatusleadingZero Specifies whether a leading zero is included in a formatted number when there are no integer digits to the left of the decimal separator.Booleanif this property is assigned a null value. TypeErrorTypeErrordependent on the locale and operating system. Specifies whether a leading zero is included in a formatted number when there are no integer digits to the left of the decimal separator.

When this property is set to true a leading zero is included to the left of the decimal separator when formatting numeric values between -1.0 and 1.0. When this property is set to false a leading zero is not included.

For example if the number is 0.321 and this property is set true, then the leading zero is included in the formatted string. If the property is set to false, the leading zero is not included. In that case the string would just include the decimal separator followed by the decimal digits, like .321.

The following table shows examples of how numbers are formatted based on the values of this property and the related fractionalDigits and trailingZeros properties.

trailingZerosleadingZerofractionalDigits0.120truetrue30.1200.000falsetrue30.120truefalse3.120.000falsefalse3.120

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

formatInt()formatNumber()formatUInt()trailingZeroslastOperationStatusLastOperationStatus
negativeNumberFormat A numeric value that indicates a formatting pattern for negative numbers.uintif the assigned value is not a number between 0 and 4. ArgumentErrorArgumentErrordependent on the locale and operating system. A numeric value that indicates a formatting pattern for negative numbers. This pattern defines the location of the negative symbol or parentheses in relation to the numeric portion of the formatted number.

The following table summarizes the possible formats for negative numbers. When a negative number is formatted, the minus sign in the format is replaced with the value of the negativeSymbol property and the 'n' character is replaced with the formatted numeric value.

Negative number format typeFormat0(n)1-n2- n3n-4n -

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

negativeSymbolformatInt()formatNumber()formatUInt()lastOperationStatusLastOperationStatus
negativeSymbol The negative symbol to be used when formatting negative values.Stringif the system cannot allocate enough internal memory. MemoryErrorflash.errors:MemoryError The negative symbol to be used when formatting negative values.

This symbol is used with the negative number format when formatting a number that is less than zero. It is not used in negative number formats that do not include a negative sign (e.g. when negative numbers are enclosed in parentheses).

This property is set to a default value for the actual locale selected when this formatter is constructed. It can be set with a value to override the default setting.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

negativeNumberFormatformatInt()formatNumber()formatUInt()lastOperationStatusLastOperationStatus
requestedLocaleIDName The name of the requested locale ID that was passed to the constructor of this NumberFormatter object.String The name of the requested locale ID that was passed to the constructor of this NumberFormatter object.

If the LocaleID.DEFAULT value was used then the name returned is "i-default". The actual locale used can differ from the requested locale when a fallback locale is applied. The name of the actual locale can be retrieved using the actualLocaleIDName property.

LocaleIDactualLocaleIDNameNumberFormatter()
trailingZeros Specifies whether trailing zeros are included in a formatted number.Booleanif this property is assigned a null value. TypeErrorTypeErrordependent on the locale and operating system. Specifies whether trailing zeros are included in a formatted number.

When this property is set to true, trailing zeros are included in the fractional part of the formatted number up to the limit specified by the fractionalDigits property. When this property is set to false then no trailing zeros are shown.

For example if the numeric value is 123.4, and this property is set true, and the fractionalDigits property is set to 3, the formatted string would show trailing zeros, like 123.400 . If this property is false, trailing zeros are not included, and the string shows just the decimal separator followed by the non-zero decimal digits, like 123.4 .

The following table shows examples of how numeric values are formatted based on the values of this property and the related fractionalDigits and leadingZero properties.

trailingZerosleadingZerofractionalDigits0.120truetrue30.1200.000falsetrue30.120truefalse3.120.000falsefalse3.120

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

leadingZerolastOperationStatusLastOperationStatus
useGrouping Enables the use of the grouping separator when formatting numbers.Boolean Enables the use of the grouping separator when formatting numbers.

When the useGrouping property is set to true, digits are grouped and delimited by the grouping separator character. For example: 123,456,789.22

When the useGrouping property is set to false, digits are not grouped or separated. For example: 123456789.22

The symbol to be used as a grouping separator is defined by the groupingSeparator property. The number of digits between grouping separators is defined by the groupingPattern property.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

groupingPatterngroupingSeparatorlastOperationStatusLastOperationStatus
DateTimeNameContext The DateTimeNameContext class enumerates constant values representing the formatting context in which a month name or weekday name is used.Object The DateTimeNameContext class enumerates constant values representing the formatting context in which a month name or weekday name is used. These constants are used for the context parameters for the DateTimeFormatter's getMonthNames() and getWeekDayNames() methods.

The context parameter only changes the results of those methods for certain locales and operating systems. For most locales the lists of month names and weekday names do not differ by context.

DateTimeFormatter.getMonthNames()DateTimeFormatter.getWeekDayNames()FORMAT Indicates that the date element name is used within a date format.formatString Indicates that the date element name is used within a date format. STANDALONE Indicates that the date element name is used in a "stand alone" context, independent of other formats.standaloneString Indicates that the date element name is used in a "stand alone" context, independent of other formats. For example, the name can be used to show only the month name in a calendar or the weekday name in a date chooser.
DateTimeNameStyle The DateTimeNameStyle class enumerates constants that control the length of the month names and weekday names that are used when formatting dates.Object The DateTimeNameStyle class enumerates constants that control the length of the month names and weekday names that are used when formatting dates. Use these constants for the nameStyle parameter of the DateTimeFormatter getMonthNames() and getWeekDayNames() methods.

The LONG_ABBREVIATION and SHORT_ABBREVIATION may be the same or different depending on the operating system settings.

DateTimeFormatterFULL Specifies the full form or full name style for month names and weekday names.fullString Specifies the full form or full name style for month names and weekday names. Examples: Tuesday, November. LONG_ABBREVIATION Specifies the long abbreviation style for month names and weekday names.longAbbreviationString Specifies the long abbreviation style for month names and weekday names. Examples: Tues for Tuesday, Nov for November. SHORT_ABBREVIATION Specifies the short abbreviation style for month names and weekday names.shortAbbreviationString Specifies the short abbreviation style for month names and weekday names. Examples: T for Tuesday, N for November.
CurrencyFormatter The CurrencyFormatter class provides locale-sensitive formatting and parsing of currency values.Object The CurrencyFormatter class provides locale-sensitive formatting and parsing of currency values.

The CurrencyFormatter class uses the data and functionality provided by the operating system and is designed to format currency values according to the conventions of a specific locale and type of currency. The position of the currency symbol, the negative symbol, the decimal separator, the grouping separator, the grouping pattern decimal separator, and other elements can vary depending on the locale.

If the operating system supports the requested locale, the properties and currency type are set according to the conventions and defaults of the requested locale. If the requested locale is not available, then the properties are set according to a fallback or default system locale, which can be retrieved using the actualLocaleIDName property.

Due to the use of the user's settings, the use of formatting patterns provided by the operating system, and the use of a fallback locale when a requested locale is not supported, different users can see different formatting results, even when using the same locale ID.

The following shows how a currency amount is formatted differently based on different locales and currencies. The results from this example will differ based on your operating system and user preferences.

This example uses the following locales:

  • The default operating system locale for currency formatting (LocaleID.DEFAULT)
  • Japanese (Japan)
  • English (US)
  • French (France)

The example does the following for each locale in the list:

  1. Creates a CurrencyFormatter object
  2. Uses the formattingWithCurrencySymbolIsSafe() method to check whether the default currency for the locale is Euros ("EUR") and if so it formats the string using the currency symbol. Otherwise it formats the string using the ISO code.
package { import flash.display.Sprite; import flash.globalization.CurrencyFormatter; import flash.globalization.LocaleID; public class CurrencyFormatterExample1 extends Sprite { public function CurrencyFormatterExample1():void { var cf:CurrencyFormatter; var amountWithSymbol:String; var amountWithISOCode:String var localeNames:Array = [LocaleID.DEFAULT, "ja-JP", "en-US", "fr-FR"]; for each (var localeName:String in localeNames) { cf = new CurrencyFormatter(localeName); trace('\n' + "LocaleID requested=" + cf.requestedLocaleIDName + "; actual=" + cf.actualLocaleIDName); trace("Last Operation Status: " + cf.lastOperationStatus ); trace("Currency ISO Code: " + cf.currencyISOCode); if (cf.formattingWithCurrencySymbolIsSafe("EUR")) { amountWithSymbol = cf.format(123456789.19, true); trace("Format using Symbol: "+ amountWithSymbol); } else { amountWithISOCode = cf.format(123456789.19); trace("Format using ISO Code: " + amountWithISOCode); } } } } }
The following example parses a currency amount using the rules for a given locale. The results from this example may differ based on your operating system and user preferences.

This example takes the following steps:

  1. Creates a CurrencyFormatter object for the English (US) locale.
  2. Uses the parse() method to parse the input string.
  3. Displays the amount and currency string values from the resulting CurrencyParseResult object.
package { import flash.display.Sprite; import flash.globalization.CurrencyFormatter; import flash.globalization.CurrencyParseResult; import flash.globalization.LastOperationStatus; import flash.globalization.LocaleID; public class CurrencyFormatterParseExample extends Sprite { public function CurrencyFormatterParseExample() { var cf:CurrencyFormatter = new CurrencyFormatter( "en_US" ); trace("LocaleID requested=" + cf.requestedLocaleIDName + "; actual=" + cf.actualLocaleIDName); trace("Last Operation Status: " + cf.lastOperationStatus ); var inputString:String = "Dollar 123,567,89,0.254"; var result:CurrencyParseResult = cf.parse(inputString); if (cf.lastOperationStatus == LastOperationStatus.NO_ERROR ) { trace("Amount value: " + result.value); trace("Currency string: " + result.currencyString); } } } }
CurrencyFormatter Constructs a new CurrencyFormatter object to format numbers representing currency amounts according to the conventions of a given locale.if the requestedLocaleIDName parameter is null. TypeErrorTypeErrorrequestedLocaleIDNameStringThe preferred locale ID name to use when determining date or time formats. Constructs a new CurrencyFormatter object to format numbers representing currency amounts according to the conventions of a given locale.

This constructor determines if the current operating system supports the requested locale ID name. If it is not supported then a fallback locale is used instead. If a fallback locale is used then the lastOperationStatus property indicates the type of fallback, and the actualLocaleIDName property contains the name of the fallback locale ID.

Certain properties such as the currencySymbol and currencyISOCode properties are set automatically based on the locale.

NOTE: When a fallback locale is used the currency properties are set to default values, and therefore the currencySymbol or currencyISOCode properties might be given unexpected values. It is a good idea to examine the currencySymbol and currencyISOCode property values before formatting a currency amount.

To format based on the user's current operating system preferences, pass the value LocaleID.DEFAULT in the requestedLocaleIDName parameter to the constructor.

When the constructor is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

When the requested locale ID name is not available then the lastOperationStatus is set to one of the following:

  • LastOperationStatus.USING_FALLBACK_WARNING
  • LastOperationStatus.USING_DEFAULT_WARNING

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

For details on the warnings listed above and other possible values of the lastOperationStatus property, see the descriptions in the LastOperationStatus class.

lastOperationStatusrequestedLocaleIDNameactualLocaleIDNameLastOperationStatusLocaleID
format Creates a string representing a currency amount formatted according to the current properties of this CurrencyFormatter object, including the locale, currency symbol, and currency ISO code.A string containing the formatted currency value. StringvalueNumberThe numeric value to be formatted into a currency string. withCurrencySymbolBooleanfalseWhen set to false the currencyISOCode property determines which currency string or symbol to use in the output string. When set to true, the current value of the currencySymbol property is used in the output string. Creates a string representing a currency amount formatted according to the current properties of this CurrencyFormatter object, including the locale, currency symbol, and currency ISO code.

By default this method uses the currencyISOCode property to determine the currency symbol and other settings used when formatting.

Many countries and regions use the same currency symbols for different currencies. For example the United States, Australia, New Zealand, Canada, and Mexico all use the same dollar sign symbol ($) for local currency values. When the formatting currency differs from the user's local currency it is best to use the ISO code as the currency string. You can use the formattingWithCurrencySymbolIsSafe() method to test whether the ISO code of the currency to be formatted matches the currencyISOCode property of the formatter.

This method can format numbers of very large and very small magnitudes. However the number of significant digits is limited to the precision provided by the Number data type.

In this example the requested locale is fr-CA French (Canada). The example assumes that this locale is supported in the user's operating system and therefore no fallback locale is used. For fr-CA the default currency is Canadian dollars with an ISO code of CAD. Therefore when formatting a currency with the default values, CAD is used as the currency symbol. When the withCurrencySymbol parameter is set to true the currencySymbol property is used to format the currency amount. var cf:CurrencyFormatter = new CurrencyFormatter("fr-CA"); trace(cf.actualLocaleIDName); // "fr-CA" trace(cf.currencyISOCode); // "CAD" trace(cf.currencySymbol); // "$" trace(cf.format(1254.56)); // "1 254,56 CAD" trace(cf.format(1254.56, true)); // "1 254,56 $"

The second example shows a method of formatting a currency amount in Canadian dollars using the default user's locale. The formattingWithCurrencySymbolIsSafe() method is used to test to see if the user's default currency is Canadian dollars and if so then the format method is used with the withCurrencySymbol parameter set to true. Otherwise the currency is set to Canadian dollars with a more descriptive currency symbol. The example shows how the currency would be formatted if the default locale was either French (Canada) or English (USA).

var cf:CurrencyFormatter = new CurrencyFormatter(LocaleID.DEFAULT); if (cf.formattingWithCurrencySymbolIsSafe("CAD")) { trace(cf.actualLocaleIDName); // "fr-CA French (Canada)" trace(cf.format(1254.56, false)); // "1 254,56 $" } else { trace(cf.actualLocaleIDName); // "en-US English (USA)" cf.setCurrency("CAD", "C$") trace(cf.format(1254.56, true)); // "C$ 1,254.56" }
currencySymbolcurrencyISOCodeformattingWithCurrencySymbolIsSafe()lastOperationStatusLastOperationStatus
formattingWithCurrencySymbolIsSafe Determines whether the currently specified currency symbol can be used when formatting currency amounts.if the requestedISOCode parameter is null. TypeErrorTypeErrortrue if the currencyISOCode property matches the requestedISOCode parameter; otherwise false. BooleanrequestedISOCodeStringA three letter ISO 4217 currency code (for example, USD for US dollars, EUR for Euros). Must contain three uppercase letters from A to Z. Determines whether the currently specified currency symbol can be used when formatting currency amounts.

Many regions and countries use the same currency symbols. This method can be used to safeguard against the use of an ambiguous currency symbol, or a currency symbol or ISO code that is different than expected due to the use of a fallback locale.

A common use case for this method is to determine whether to show a local currency symbol (if the amount is formatted in the user's default currency), or a more specific ISO code string (if the amount is formatted in a currency different from the user's default).

This method compares the requestedISOCode parameter against the current currencyISOCode property, returning true if the strings are equal and false if they are not. When the strings are equal, using the format() method with the withCurrencySymbol parameter set to true results in a formatted currency value string with a unique currency symbol for the locale. If this method returns false, then using the format() method with the withCurrencySymbol parameter set to true could result in the use of an ambiguous or incorrect currency symbol.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

currencySymbolcurrencyISOCodelastOperationStatusLastOperationStatus
getAvailableLocaleIDNames Lists all of the locale ID names supported by this class.A vector of strings containing all of the locale ID names supported by this class. Lists all of the locale ID names supported by this class.

If this class is not supported on the current operating system, this method returns a null value.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

parse Parses a string into a currency amount and a currency symbol.if the inputString parameter is null. TypeErrorTypeErrorA CurrencyParseResult object containing the numeric value and the currency symbol or string. flash.globalization:CurrencyParseResultinputStringStringThe input string to parse. Parses a string into a currency amount and a currency symbol.

The parsing algorithm uses the value of the decimalSeparator property to determine the integral and fractional portion of the number. It uses the values of the negativeCurrencyFormat and positiveCurrencyFormat properties to determine the location of the currency symbol or string relative to the currency amount. For negative amounts the value of the negativeCurrencyFormat property determines the location of the negative symbol and whether parentheses are used.

If the order of the currency symbol, minus sign, and number in the input string does not match the pattern identified by the negativeCurrencyFormat and positiveCurrencyFormat properties, then:

  1. The value property of the returned CurrencyParseResult object is set to NaN.
  2. The currencyString property of the returned CurrencyParseResult object is set to null.
  3. The lastOperationStatus property is set to indicate that parsing failed.

The input string may include space characters, which are ignored during the parsing.

Parsing can succeed even if there is no currency symbol. No validation is done of the portion of the string corresponding to the currency symbol. If there is no currency symbol or string, the currencyString property in the returned CurrencyParseResult object is set to an empty string.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

decimalSeparatornegativeCurrencyFormatpositiveCurrencyFormatCurrencyParseResultlastOperationStatusLastOperationStatus
setCurrency Sets the currencyISOCode and currencySymbol properties of the CurrencyFormatter object.if the currencyISOCode or currencySymbol parameter is null. TypeErrorTypeErrordependent on the actual locale and operating system currencyISOCodeStringThe three letter ISO 4217 currency code (for example, USD for US dollars, EUR for Euros). Must contain three uppercase letters from A to Z. currencySymbolString The currency symbol or string to be used when formatting currency values. This can be an empty string. Sets the currencyISOCode and currencySymbol properties of the CurrencyFormatter object.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the the currencyISOCode and the currencySymbol properties are not modified and the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

currencyISOCodecurrencySymbollastOperationStatusLastOperationStatus
actualLocaleIDName The name of the actual locale ID used by this CurrencyFormatter object.String The name of the actual locale ID used by this CurrencyFormatter object.

There are three possibilities for the value of the name, depending on operating system and the value of the requestedLocaleIDName parameter passed to the CurrencyFormatter() constructor.

  1. If the requested locale was not LocaleID.DEFAULT and the operating system provides support for the requested locale, then the name returned is the same as the requestedLocaleIDName property.
  2. If LocaleID.DEFAULT was used as the value for the requestedLocaleIDName parameter to the constructor, then the name of the current locale specified by the user's operating system is used. The LocaleID.DEFAULT value preserves user's customized setting in the OS. Passing an explicit value as the requestedLocaleIDName parameter does not necessarily give the same result as using the LocaleID.DEFAULT even if the two locale ID names are the same. The user might have customized the locale settings on their machine, and by requesting an explicit locale ID name rather than using LocaleID.DEFAULT your application would not retrieve those customized settings.

    For example:

    var fmt:CurrencyFormatter = new CurrencyFormatter(LocaleID.DEFAULT); var aliName:String = fmt.actualLocaleIDName;

    In the above example, aliName is the name of the locale corresponding to the user's current operating systems settings (for example, "it-IT" if the user's locale is set to Italian-Italy), and not "i-default" (the name of the LocaleID.DEFAULT locale).

  3. If the system does not support the requestedLocaleIDName specified in the constructor then a fallback locale ID name is provided.

    For Example:

    var fmt:CurrencyFormatter = new CurrencyFormatter("fr-CA"); var aliName:String = fmt.actualLocaleIDName;

    Assuming that the operating system in the example above does not support the "fr-CA" (French-Canada) locale ID, a fallback is used. In this case the fallback locale ID is "fr-FR" (French-France).

LocaleIDrequestedLocaleIDNameCurrencyFormatter()
currencyISOCode The three letter ISO 4217 currency code for the actual locale being used.Stringdependent on the actual locale and operating system The three letter ISO 4217 currency code for the actual locale being used.

This code is used to determine the currency symbol or string when formatting currency amounts using the format() method with the withCurrencySymbol parameter set to false.

This property is initialized by the constructor based on the actual locale that is used. When a fallback locale is used this property reflects the preferred, default currency code for the fallback locale.

format()setCurrency()currencySymbol
currencySymbol The currency symbol or string for the actual locale being used.Stringdependent on the actual locale and operating system The currency symbol or string for the actual locale being used.

This property is used as the currency symbol when formatting currency amounts using the format() method with the withCurrencySymbol parameter set to true.

This property is initialized by the constructor based on the actual locale that is used. When a fallback locale is used this property reflects the preferred, default currency symbol for the fallback locale.

format()setCurrency()formattingWithCurrencySymbolIsSafe()currencyISOCode
decimalSeparator The decimal separator character used for formatting or parsing currency amounts that have a decimal part.Stringif this property is assigned a null value. TypeErrorTypeErrordependent on the actual locale and operating system The decimal separator character used for formatting or parsing currency amounts that have a decimal part.

This property is initially set based on the locale that is selected when the formatter object is constructed.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

format()lastOperationStatusLastOperationStatus
digitsType Defines the set of digit characters used when formatting currency amounts.uintif this property is assigned a null value. TypeErrorTypeErrordependent on the actual locale and operating system Defines the set of digit characters used when formatting currency amounts.

Different languages and regions use different sets of characters to represent the digits 0 through 9. This property defines the set of digits to be used.

The value of this property represents the Unicode value for the zero digit of a decimal digit set. The valid values for this property are defined in the NationalDigitsType class.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatusLastOperationStatusNationalDigitsType
fractionalDigits The maximum number of digits that can appear after the decimal separator.int0 The maximum number of digits that can appear after the decimal separator.

Numbers are rounded to the number of digits specified by this property. The rounding scheme varies depending on the user's operating system.

When the trailingZeros property is set to true, the fractional portion of the number (after the decimal point) is padded with trailing zeros until its length matches the value of this fractionalDigits property.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

trailingZeroslastOperationStatusLastOperationStatus
groupingPattern Describes the placement of grouping separators within the formatted currency amount string.Stringif this property is assigned a null value. TypeErrorTypeError Describes the placement of grouping separators within the formatted currency amount string.

When the useGrouping property is set to true, the groupingPattern property is used to define the placement and pattern used for the grouping separator.

The grouping pattern is defined as a string containing numbers separated by semicolons and optionally may end with an asterisk. For example: "3;2;*". Each number in the string represents the number of digits in a group. The grouping separator is placed before each group of digits. An asterisk at the end of the string indicates that groups with that number of digits should be repeated for the rest of the formatted string. If there is no asterisk then there are no additional groups or separators for the rest of the formatted string.

The first number in the string corresponds to the first group of digits to the left of the decimal separator. Subsequent numbers define the number of digits in subsequent groups to the left. Thus the string "3;2;*" indicates that a grouping separator is placed after the first group of 3 digits, followed by groups of 2 digits. For example: 98,76,54,321

The following table shows examples of formatting the currency amount 123456789.12 with various grouping patterns. The grouping separator is a comma, the decimal separator is a period, and a dollar sign ($) is the currency symbol.

Grouping PatternSample Format3;* $123,456,789.123;2;*$12,34,56,789.123$123456,789.12

Only a limited number of grouping sizes can be defined. On some operating systems, grouping patterns can only contain two numbers plus an asterisk. Other operating systems can support up to four numbers and an asterisk. For patterns without an asterisk, some operating systems only support one number while others support up to three numbers. If the maximum number of grouping pattern elements is exceeded, then additional elements are ignored, and the lastOperationStatus property is set as described below.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

groupingSeparatoruseGroupinglastOperationStatusLastOperationStatus
groupingSeparator The character or string used for the grouping separator.Stringif this property is assigned a null value. TypeErrorTypeErrordependent on the actual locale and operating system The character or string used for the grouping separator.

The value of this property is used as the grouping separator when formatting currency amounts when the useGrouping property is set to true. This property is initially set based on the locale that is selected when the formatter object is constructed.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

format()useGroupinglastOperationStatusLastOperationStatus
lastOperationStatus The status of the most recent operation that this CurrencyFormatter object performed.String The status of the most recent operation that this CurrencyFormatter object performed. The lastOperationStatus property is set whenever the constructor or a method of this class is called or another property is set. For the possible values see the description for each method. LastOperationStatusleadingZero Specifies whether a leading zero is included in a formatted currency amount when there are no integer digits to the left of the decimal separator.Booleanif this property is assigned a null value. TypeErrorTypeErrordependent on the actual locale and operating system Specifies whether a leading zero is included in a formatted currency amount when there are no integer digits to the left of the decimal separator.

When this property is set to true a leading zero is included to the left of the decimal separator when formatting numeric values between -1.0 and 1.0. When this property is set to false a leading zero is not included.

For example if the currency amount is 0.321 and this property is set true, then the leading zero is included in the formatted string. If the property is set to false, the leading zero is not included. In that case the string would just include the decimal separator followed by the decimal digits, like $.321.

The following table shows examples of how currency amounts are formatted based on the values of this property and the related fractionalDigits and trailingZeros properties.

trailingZerosleadingZerofractionalDigits0.120truetrue3$0.120$0.000falsetrue3$0.12$0truefalse3$.120$.000falsefalse3$.12$0

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

format()lastOperationStatusLastOperationStatustrailingZeros
negativeCurrencyFormat A numeric value that indicates a formatting pattern for negative currency amounts.uintif the assigned value is not between 0 and 15. ArgumentErrorArgumentErrordependent on the actual locale and operating system A numeric value that indicates a formatting pattern for negative currency amounts. This pattern defines the location of the currency symbol and the negative symbol or parentheses in relation to the numeric portion of the currency amount.

The value of this property must be one of the constants defined in the table below.

The table below summarizes the possible formatting patterns for negative currency amounts. When a currency amount is formatted with the format() method:

  • The '¤' symbol is replaced with the value of the currencyISOCode or the currencySymbol property, depending on the value of the withCurrencySymbol parameter passed to the format() method;
  • The '-' character is replaced with the value of the negativeNumberSymbol property;
  • The 'n' character is replaced with the currency amount value that is passed to the format() method.
Negative currency format typeFormatting pattern0(¤n)1-¤n2¤-n3¤n-4(n¤)5-n¤6n-¤7n¤-8-n ¤9-¤ n10n ¤-11¤ n-12¤ -n13n- ¤14(¤ n)15(n ¤)

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

format()currencySymbolnegativeSymbollastOperationStatusLastOperationStatus
negativeSymbol The negative symbol used when formatting negative currency amounts.Stringif this property is assigned a null value. TypeErrorTypeErrordependent on the actual locale and operating system The negative symbol used when formatting negative currency amounts.

This symbol is used with the negative currency format when formatting a currency amount that is less than zero. It is not used in negative currency formats that do not include a negative sign (for example, when negative currency amounts are enclosed in parentheses).

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

format()negativeCurrencyFormatlastOperationStatusLastOperationStatus
positiveCurrencyFormat A numeric value that indicates a formatting pattern for positive currency amounts.uintif the assigned value is not between 0 and 3. ArgumentErrorArgumentErrordependent on the actual locale and operating system A numeric value that indicates a formatting pattern for positive currency amounts. This format defines the location of currency symbol relative to the numeric portion of the currency amount.

The value of this property must be one of the constants defined in the table below.

The table below summarizes the possible formatting patterns for positive currency amounts. When a currency amount is formatted with the format() method:

  • The '¤' symbol is replaced with the value of the currencyISOCode or the currencySymbol property, depending on the value of the withCurrencySymbol parameter passed to the format() method;
  • The 'n' character is replaced with the currency amount value that is passed to the format() method.
Positive currency format typeFormatting pattern0¤n12¤ n3n ¤

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

currencySymbolformat()lastOperationStatusLastOperationStatus
requestedLocaleIDName The name of the requested locale ID that was passed to the constructor of this CurrencyFormatter object.String The name of the requested locale ID that was passed to the constructor of this CurrencyFormatter object.

If the LocaleID.DEFAULT value was used then the name returned is "i-default". The actual locale used can differ from the requested locale when a fallback locale is applied. The name of the actual locale can be retrieved using the actualLocaleIDName property.

LocaleIDactualLocaleIDNameCurrencyFormatter()
trailingZeros Specifies whether trailing zeros are included in the formatted currency amount.Booleanif this property is assigned a null value. TypeErrorTypeErrordependent on the actual locale and operating system Specifies whether trailing zeros are included in the formatted currency amount.

When this property is set to true, trailing zeros are included in the fractional part of the formatted number up the limit specified by the fractionalDigits property. When this property is set to false then no trailing zeros are shown.

For example if the currency amount is 123.4, and this property is set true, and the fractionalDigits property is set to 3, the formatted string would show trailing zeros, like $123.400 . If this property is false, trailing zeros are not included, and the string shows just the decimal separator followed by the non-zero decimal digits, like $123.4 .

The following table shows examples of how currency amounts are formatted based on the values of this property and the related fractionalDigits and leadingZero properties.

trailingZerosleadingZerofractionalDigits0.120truetrue3$0.120$0.000falsetrue3$0.12$0truefalse3$.120$.000falsefalse3$.12$0

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

leadingZerolastOperationStatusLastOperationStatus
useGrouping Enables the use of the grouping separator when formatting currency amounts.Boolean Enables the use of the grouping separator when formatting currency amounts.

When the useGrouping property is set to true, digits are grouped and delimited by the grouping separator character. For example: $123,456,789

When the useGrouping property is set to false, digits are not grouped or separated. For example: $123456789

The groupingSeparator property defines the symbol to be used as a grouping separator. The groupingPattern property defines the number of digits between grouping separators.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

groupingPatterngroupingSeparatorlastOperationStatusLastOperationStatus
Collator The Collator class provides locale-sensitive string comparison capabilities.Object The Collator class provides locale-sensitive string comparison capabilities.

This class uses the string comparison services provided by the operating system. The comparisons differ according to the locale identifier that is provided when the class instance is created. ActionScript stores strings using the Unicode character set. The Boolean string comparison operators (==, !=, <, <=, >, >=) use Unicode code points for comparison. In most cases the resulting sort order doesn't match the conventions of a particular language and region, and thus should not be used to sort strings that are presented in a user interface. In contrast the comparison methods in this class provide an order that adheres to these conventions.

Here are some examples where the sort order differs depending on the language:

  • In English, lowercase a is before uppercase A and uppercase A is before lowercase b.
  • ö is after z in Swedish, whereas in German ö is after o
  • ch is sorted as one character between c-d in traditional Spanish
  • accented characters in French are sorted according to the last accent difference instead of the first accent difference: for example, cote < côte < coté < côté instead of cote < coté < côte < côté

Sort orders can even differ within the same language and region depending on the usage. For example, in German there is a different sort order used for names in a phone book versus words in a dictionary. In Chinese and Japanese there are different ways of sorting the ideographic characters: by pronunciation or by the ideographic radical and the number of strokes uses in the glyph. In Spanish and Georgian, there is a difference between modern and traditional sorting.

The comparison methods in this class provide two main usage modes. The initialMode parameter of the Collator() constructor controls these modes. The default "sorting" mode is for sorting items that are displayed to an end user. In this mode, comparison is more strict to ensure that items that are otherwise the same are sorted in a consistent manner. For example, uppercase letters and lowercase letters do not compare as equal. In the "matching" mode the comparison is more lenient. For example in this mode uppercase and lowercase letters are treated equally. Here's an example that demonstrates both of these modes:

var sortingCollator:Collator = new Collator("en-US", CollatorMode.SORTING); var words:Array = new Array("Airplane" , "airplane", "boat", "Boat"); words.sort(sortingCollator.compare); trace(words); var matchingCollator:Collator = new Collator("en-US", CollatorMode.MATCHING); if (matchingCollator.equals("Car", "car")) { trace("The words match!"); }

Even when providing a locale ID parameter to the constructor as shown above, collation behavior can differ by user based on the user's operating system settings and whether a fallback locale is used when the requested locale is not supported.

The following example shows sorting results that differ based on the locale. The example takes the following steps:
  1. Iterates through an array of locale ID names, including the default locale ID for the operating system (as specified by LocaleID.DEFAULT)
  2. Creates a Collator object for each locale ID name using "sorting" mode (the default).
  3. Displays the requested and actual locale ID names and the value of the lastOperationStatus property so you can see if a fallback locale was used.
  4. Sorts a data array using each collator and displays the results. The resulting order is different for each locale.
package { import flash.globalization.Collator; import flash.globalization.LocaleID; public class CollatorExample1 { public var col:Collator; public function CollatorExample1():void { var localeNames:Array = [LocaleID.DEFAULT, "de-DE", "sv-SE", "fr-FR", "lt-LT", "es-ES"]; var testSortData:Array = [ "y ", "i ", "k ", // Latvian "acxa ", "acha ", "adxa ", // es_traditional "n ", "ö ", "o ", "z ", "vu ", "wo ", // sw "däd ", "daed ", // de "öf ", "of ", // de_dictionary "côte ", "coté " // fr ]; for each (var localeName:String in localeNames) { col = new Collator(localeName); trace("LocaleID requested: " + col.requestedLocaleIDName + "; actual: " + col.actualLocaleIDName); trace("Last Operation Status: " + col.lastOperationStatus ); var result:Array = testSortData.sort(col.compare); trace ("sorted data: " + result); } } } }
The following examples shows uses a Collator object to control the behavior of string comparisons. The example takes the following steps:
  1. Creates a Collator object for the user's default locale using "matching" mode.
  2. Alternately sets the Collator.ignoreDiacritics property to false and true
  3. Compares sets of strings that contain diacritics and upper case and lower case characters.
  4. Shows how the comparisons change when the Collator.ignoreDiacritics and Collator.ignoreCase properties change.
package { import flash.display.Sprite; import flash.globalization.Collator; import flash.globalization.CollatorMode; import flash.globalization.LocaleID; public class CollatorExample2 extends Sprite { public var col:Collator; public var testMatchData:Array = ["cote", "Cote", "côte", "coté"]; public var wordToMatch:String = "Cote"; public function CollatorExample2() { col = new Collator( LocaleID.DEFAULT, CollatorMode.MATCHING ); trace("LocaleID requested: " + col.requestedLocaleIDName + "; actual: " + col.actualLocaleIDName); trace("Last Operation Status: " + col.lastOperationStatus ); trace('\n' + "ignoreCase = " + col.ignoreCase); trace("ignoreDiacritics = " + col.ignoreDiacritics); compareString(testMatchData, wordToMatch) // All variations of the word cote match col.ignoreDiacritics = false; trace('\n' + "ignoreDiacritics = false"); compareString(testMatchData, wordToMatch) // Variations with different diacritics will not match col.ignoreCase = false; trace('\n' + "ignoreCase = false"); compareString(testMatchData, wordToMatch) // Variations with different case will not match } private function compareString(stringArray:Array, keyword:String):void { for each(var s:String in stringArray) { if(col.equals(s, keyword)) { trace(keyword + " = " + s); } } } } }
Collator Constructs a new Collator object to provide string comparisons according to the conventions of a specified locale.when the requestedLocaleIDName parameter is null. TypeErrorTypeErrorwhen the requestedLocaleIDName parameter contains an invalid value. ArgumentErrorArgumentErrorrequestedLocaleIDNameStringString to be used by this Collator object. initialModeStringsortingA string value to specify the initial collation mode. The default value is CollatorMode.SORTING. See the CollatorMode class for a list of available modes. Constructs a new Collator object to provide string comparisons according to the conventions of a specified locale.

If the current operating system does not support the locale ID that is passed in the requestedLocaleIDName parameter, then a fallback locale is determined. If a fallback is used then the lastOperationStatus property is set to indicate the type of fallback.

The initialMode parameter sets various collation options for general uses. It can be set to one of the following values:

  • CollatorMode.SORTING: sets collation options for general linguistic sorting usages such as sorting a list of text strings that are displayed to an end user. In this mode, differences in uppercase and lowercase letters, accented characters, and other differences specific to the locale are considered when doing string comparisons.
  • CollatorMode.MATCHING: sets collation options for general usages such as determining if two strings are equivalent. In this mode, differences in uppercase and lower case letters, accented characters, and so on are ignored when doing string comparisons.

Here is an example of a sorted list created using a Collator with the locale ID "en-US" (English in US) and the CollatorMode.SORTING option:

AaÄäAEaeÆæBbCcç

As shown above, all characters are treated as if they have different values, but in linguistic order.

Here is an example of a sorted list created using Collator with the locale ID "en-US" (English in US) and the CollatorMode.MATCHING option:

A a Ä ä A aAE ae Æ æB b B bC c ç C c

Legend: Characters in a same row are treated as equivalent characters during comparison/sorting. For example, "a" (U+0040 = LATIN SMALL LETTER A) and "Ä" (U+00C4 = LATIN CAPITAL LETTER A WITH DIAERESIS) are considered to be equal.

As shown above, some characters are in linguistic order and are treated as if they have the same character value.

For finer control over sorting order, you can change collator properties such as Collator.ignoreCase or Collator.ignoreDiacritics.

For reference, here is a corresponding sorting example done using the standard Array.sort(), which is not locale-aware:

AAEBCaaebcÄÆäæç

As you can see above, all characters are sorted simply in Unicode numeric value order. It does not make much sense linguistically.

To use the user's current operating system preferences, pass the static value LocaleID.DEFAULT in the requestedLocaleIDName parameter to the constructor.

Some locales have several sort order variants. For example, in German one sort order is used for phone books and another sort order is used for dictionaries. In Chinese, words are commonly supported by transliteration of the characters into the pinyin. These different sort orders can be selected by including the "collation" keyword in the string that is passed in the requestedLocaleIDName parameter to the constructor.

var germanPhonebook:LocaleID = new LocaleID("de-DE@collation=phonebook"); var chinesePinyin:LocaleID = new LocaleID("zh-Hant@collation=pinyin");

Possible values for the collation string are as follows, with the affected languages shown in parentheses:

Collation stringDescriptionstandardThe default ordering for each language. phonebookFor a phonebook-style ordering (used in German).pinyinPinyin ordering for Latin and for CJK characters; that is, an ordering for CJK characters based on a character-by-character transliteration into a pinyin. (used in Chinese)traditionalFor a traditional-style sort (used in Spanish) strokePinyin ordering for Latin, stroke order for CJK characters (used in Chinese)direct(used in Hindi) big5hanPinyin ordering for Latin, big5 character set ordering for CJK characters. (used in Chinese) gb2312han Pinyin ordering for Latin, gb2312han character set ordering for CJK characters. (used in Chinese) unihanPinyin ordering for Latin, Unihan radical-stroke ordering for CJK characters. (used in Chinese)

If the host platform does not support the requested collation type, then a fallback is used and the lastOperationStatus property is set to indicate that a fallback was selected. You can use the actualLocaleIDName property to determine the value that was used as a fallback, as shown in the following example:

var collator:Collator = new Collator("fr-FR"); if (collator.lastOperationStatus == LastOperationStatus.USING_FALLBACK_WARNING) { trace ("Using fallback locale: " + collator.actualLocaleIDName); }

When the constructor completes successfully, then the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

When the requested locale ID is not available, then the lastOperationStatus property is set to one of the following:

  • LastOperationStatus.USING_FALLBACK_WARNING
  • LastOperationStatus.USING_DEFAULT_WARNING

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

For details on the warnings listed above and other possible values of lastOperationStatus, see the descriptions in the LastOperationStatus class.

CollatorModeLastOperationStatusLocaleIDlastOperationStatusrequestedLocaleIDNameactualLocaleIDName
compare Compares two strings and returns an integer value indicating whether the first string is less than, equal to, or greater than the second string.when a required parameter is null. TypeErrorTypeErrorwhen a parameter contains an invalid value. ArgumentErrorArgumentErrorAn integer value indicating whether the first string is less than, equal to, or greater than the second string.
  • If the return value is negative, string1 is less than string2.
  • If the return value is zero, string1 is equal to string2.
  • If the return value is positive, string1 is larger than string2.
int
string1StringFirst comparison string. string2StringSecond comparison string.
Compares two strings and returns an integer value indicating whether the first string is less than, equal to, or greater than the second string. The comparison uses the sort order rules for the locale ID that was specified in the Collator() constructor.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

equals()lastOperationStatusLastOperationStatus
equals Compares two strings and returns a Boolean value indicating whether the strings are equal.when a required parameter is null. TypeErrorTypeErrorwhen a parameter contains an invalid value. ArgumentErrorArgumentErrorA Boolean value indicating whether the strings are equal (true) or unequal (false). Booleanstring1StringFirst comparison string. string2StringSecond comparison string. Compares two strings and returns a Boolean value indicating whether the strings are equal. The comparison uses the sort order rules for the locale ID that was specified in the Collator() constructor.

When this method is called and it completes successfully, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

compare()lastOperationStatusLastOperationStatus
getAvailableLocaleIDNames Lists all of the locale ID names supported by this class.A vector of strings containing all of the locale ID names supported by this class. Lists all of the locale ID names supported by this class.

If this class is not supported at all on the current operating system, this method returns a null value.

actualLocaleIDName The name of the actual locale ID used by this Collator object.String The name of the actual locale ID used by this Collator object.

There are three possibilities for the value of the name, depending on operating system and the value of the requestedLocaleIDName parameter passed to the Collator() constructor.

  1. If the requested locale was not LocaleID.DEFAULT and the operating system provides support for the requested locale, then the name returned is the same as the requestedLocaleIDName property.
  2. If LocaleID.DEFAULT was used as the value for the requestedLocaleIDName parameter to the constructor, then the name of the current locale specified by the user's operating system is used. The LocaleID.DEFAULT value preserves user's customized setting in the OS. Passing an explicit value as the requestedLocaleIDName parameter does not necessarily give the same result as using the LocaleID.DEFAULT even if the two locale ID names are the same. The user might have customized the locale settings on their machine, and by requesting an explicit locale ID name rather than using LocaleID.DEFAULT your application would not retrieve those customized settings.

    For example:

    var fmt:Collator = new Collator(LocaleID.DEFAULT); var aliName:String = fmt.actualLocaleIDName;

    In the above example, aliName is the name of the locale corresponding to the user's current operating systems settings (e.g. "it-IT" if the user's locale is set to Italian-Italy), and not "i-default" (the name of the LocaleID.DEFAULT locale).

  3. If the system does not support the requestedLocaleIDName specified in the constructor then a fallback locale ID name is provided.

    For Example:

    var fmt:Collator = new Collator("fr-CA"); var aliName:String = fmt.actualLocaleIDName;

    Assuming that the operating system in the example above does not support the "fr-CA" (French-Canada) locale ID, a fallback is used. In that case the aliName variable contains the fallback locale ID "fr-FR" (French-France).

LocaleIDrequestedLocaleIDName
ignoreCase When this property is set to true, identical strings and strings that differ only in the case of the letters are evaluated as equal.Boolean<code>true</code> when the <code>Collator()</code> constructor's <code>initialMode</code> parameter is set to <code>Collator.MATCHING</code>. <code>false</code> when the <code>Collator()</code> constructor's <code>initialMode</code> parameter is set to Collator.SORTING. When this property is set to true, identical strings and strings that differ only in the case of the letters are evaluated as equal. For example, compare("ABC", "abc") returns true when the ignoreCase property is set to true.

The case conversion of the string follows the rules for the specified locale.

When the ignoreCase property is false then upper- and lowercase characters are not equal to one another.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise, the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatuscompare()equals()LastOperationStatus
ignoreCharacterWidth When this property is true, full-width and half-width forms of some Chinese and Japanese characters are evaluated as equal.Booleanfalse When this property is true, full-width and half-width forms of some Chinese and Japanese characters are evaluated as equal.

For compatibility with existing standards for Chinese and Japanese character sets, Unicode provides character codes for both full-width and half width-forms of some characters. For example, when the ignoreCharacterWidth property is set to true, compare("Aア", "Aア") returns true.

If the ignoreCharacterWidth property is set to false, then full-width and half-width forms are not equal to one another.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatuscompare()equals()LastOperationStatus
ignoreDiacritics When this property is set to true, strings that use the same base characters but different accents or other diacritic marks are evaluated as equal.Booleanfalse When this property is set to true, strings that use the same base characters but different accents or other diacritic marks are evaluated as equal. For example compare("coté", "côte") returns true when the ignoreDiacritics property is set to true.

When the ignoreDiacritics is set to false then base characters with diacritic marks or accents are not considered equal to one another.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatuscompare()equals()LastOperationStatus
ignoreKanaType When this property is set to true, strings that differ only by the type of kana character being used are treated as equal.Booleanfalse When this property is set to true, strings that differ only by the type of kana character being used are treated as equal. For example, compare("カナ", "かな") returns true when the ignoreKanaType property is set to true.

If the ignoreKanaType is set to false then hiragana and katakana characters that refer to the same syllable are not equal to one another.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatuscompare()equals()LastOperationStatus
ignoreSymbols When this property is set to is true, symbol characters such as spaces, currency symbols, math symbols, and other types of symbols are ignored when sorting or matching.Booleanfalse When this property is set to is true, symbol characters such as spaces, currency symbols, math symbols, and other types of symbols are ignored when sorting or matching. For example the strings "OBrian", "O'Brian", and "O Brian" would all be treated as equal when the ignoreSymbols property is set to true.

If the ignoreSymbols property is false then symbol characters are considered in string comparisons.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatuscompare()equals()LastOperationStatus
lastOperationStatus The status of the most recent operation that this Collator object performed.String The status of the most recent operation that this Collator object performed. The lastOperationStatus is set whenever the constructor or a method of this class is called, or when a property is set. For the possible values see the description under each method. LastOperationStatusnumericComparison Controls how numeric values embedded in strings are handled during string comparison.Booleanfalse Controls how numeric values embedded in strings are handled during string comparison.

When the numericComparison property is set to true, the compare method converts numbers that appear in strings to numerical values for comparison.

When this property is set to false, the comparison treats numbers as character codes and sort them according to the rules for sorting characters in the specified locale.

For example, when this property is true for the locale ID "en-US", then the strings "version1", "version10", and "version2" are sorted into the following order: version1 < version2 < version10.

When this property is false for "en-US", those same strings are sorted into the following order: version1 < version10 < version2.

When this property is assigned a value and there are no errors or warnings, the lastOperationStatus property is set to:

  • LastOperationStatus.NO_ERROR

Otherwise the lastOperationStatus property is set to one of the constants defined in the LastOperationStatus class.

lastOperationStatuscompare()equals()LastOperationStatus
requestedLocaleIDName The name of the requested locale ID that was passed to the constructor of this Collator object.String The name of the requested locale ID that was passed to the constructor of this Collator object.

If the LocaleID.DEFAULT value was used then the name returned is "i-default". The actual locale used can differ from the requested locale when a fallback locale is applied. The name of the actual locale can be retrieved using the actualLocaleIDName property.

LocaleIDactualLocaleIDName