ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Hide Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes

Language Reference only
Filters: AIR 32.0 and earlier, Flash Player 32.0 and earlier, Flash Lite 4
Flex 4.6 and earlier, Flash Pro CS6 and earlier
Hide Filters
flash.globalization 

DateTimeFormatter  - AS3

Packagesx

Top Level
adobe.utils
air.desktop
air.net
air.update
air.update.events
coldfusion.air
coldfusion.air.errors
coldfusion.air.events
coldfusion.service
coldfusion.service.events
coldfusion.service.mxml
com.adobe.acm.solutions.authoring.domain.extensions
com.adobe.acm.solutions.ccr.domain.extensions
com.adobe.consulting.pst.vo
com.adobe.dct.component
com.adobe.dct.component.datadictionary
com.adobe.dct.component.datadictionaryElement
com.adobe.dct.component.dataElementsPanel
com.adobe.dct.component.toolbars
com.adobe.dct.event
com.adobe.dct.exp
com.adobe.dct.model
com.adobe.dct.service
com.adobe.dct.service.provider
com.adobe.dct.transfer
com.adobe.dct.util
com.adobe.dct.view
com.adobe.ep.taskmanagement.domain
com.adobe.ep.taskmanagement.event
com.adobe.ep.taskmanagement.filter
com.adobe.ep.taskmanagement.services
com.adobe.ep.taskmanagement.util
com.adobe.ep.ux.attachmentlist.component
com.adobe.ep.ux.attachmentlist.domain
com.adobe.ep.ux.attachmentlist.domain.events
com.adobe.ep.ux.attachmentlist.domain.renderers
com.adobe.ep.ux.attachmentlist.skin
com.adobe.ep.ux.attachmentlist.skin.renderers
com.adobe.ep.ux.content.event
com.adobe.ep.ux.content.factory
com.adobe.ep.ux.content.handlers
com.adobe.ep.ux.content.managers
com.adobe.ep.ux.content.model.asset
com.adobe.ep.ux.content.model.preview
com.adobe.ep.ux.content.model.relation
com.adobe.ep.ux.content.model.search
com.adobe.ep.ux.content.model.toolbar
com.adobe.ep.ux.content.search
com.adobe.ep.ux.content.services
com.adobe.ep.ux.content.services.load
com.adobe.ep.ux.content.services.permissions
com.adobe.ep.ux.content.services.preview
com.adobe.ep.ux.content.services.providers
com.adobe.ep.ux.content.services.query
com.adobe.ep.ux.content.services.relationships
com.adobe.ep.ux.content.services.search.lccontent
com.adobe.ep.ux.content.services.version
com.adobe.ep.ux.content.view
com.adobe.ep.ux.content.view.components.activate
com.adobe.ep.ux.content.view.components.grid
com.adobe.ep.ux.content.view.components.grid.hover
com.adobe.ep.ux.content.view.components.grid.hover.component
com.adobe.ep.ux.content.view.components.grid.renderers
com.adobe.ep.ux.content.view.components.relationships
com.adobe.ep.ux.content.view.components.review
com.adobe.ep.ux.content.view.components.search.renderers
com.adobe.ep.ux.content.view.components.searchpod
com.adobe.ep.ux.content.view.components.toolbar
com.adobe.ep.ux.content.view.components.toolbar.controlRenderers
com.adobe.ep.ux.content.view.components.version
com.adobe.ep.ux.documentsubmit.component
com.adobe.ep.ux.documentsubmit.domain
com.adobe.ep.ux.documentsubmit.skin
com.adobe.ep.ux.taskaction.component
com.adobe.ep.ux.taskaction.domain
com.adobe.ep.ux.taskaction.domain.events
com.adobe.ep.ux.taskaction.skin
com.adobe.ep.ux.taskdetails.component
com.adobe.ep.ux.taskdetails.domain
com.adobe.ep.ux.taskdetails.skin
com.adobe.ep.ux.tasklist.component
com.adobe.ep.ux.tasklist.domain
com.adobe.ep.ux.tasklist.skin
com.adobe.ep.ux.webdocumentviewer.domain
com.adobe.exm.expression
com.adobe.exm.expression.error
com.adobe.exm.expression.event
com.adobe.exm.expression.impl
com.adobe.fiber.runtime.lib
com.adobe.fiber.services
com.adobe.fiber.services.wrapper
com.adobe.fiber.styles
com.adobe.fiber.util
com.adobe.fiber.valueobjects
com.adobe.gravity.binding
com.adobe.gravity.context
com.adobe.gravity.flex.bundleloader
com.adobe.gravity.flex.progress
com.adobe.gravity.flex.serviceloader
com.adobe.gravity.framework
com.adobe.gravity.init
com.adobe.gravity.service.bundleloader
com.adobe.gravity.service.logging
com.adobe.gravity.service.manifest
com.adobe.gravity.service.progress
com.adobe.gravity.tracker
com.adobe.gravity.ui
com.adobe.gravity.utility
com.adobe.gravity.utility.async
com.adobe.gravity.utility.error
com.adobe.gravity.utility.events
com.adobe.gravity.utility.factory
com.adobe.gravity.utility.flex.async
com.adobe.gravity.utility.logging
com.adobe.gravity.utility.message
com.adobe.gravity.utility.sequence
com.adobe.gravity.utility.url
com.adobe.guides.control
com.adobe.guides.domain
com.adobe.guides.i18n
com.adobe.guides.spark.components.skins
com.adobe.guides.spark.components.skins.mx
com.adobe.guides.spark.headers.components
com.adobe.guides.spark.headers.skins
com.adobe.guides.spark.layouts.components
com.adobe.guides.spark.layouts.skins
com.adobe.guides.spark.navigators.components
com.adobe.guides.spark.navigators.renderers
com.adobe.guides.spark.navigators.skins
com.adobe.guides.spark.util
com.adobe.guides.spark.wrappers.components
com.adobe.guides.spark.wrappers.skins
com.adobe.guides.submit
com.adobe.icc.dc.domain
com.adobe.icc.dc.domain.factory
com.adobe.icc.editors.events
com.adobe.icc.editors.handlers
com.adobe.icc.editors.managers
com.adobe.icc.editors.model
com.adobe.icc.editors.model.config
com.adobe.icc.editors.model.el
com.adobe.icc.editors.model.el.operands
com.adobe.icc.editors.model.el.operators
com.adobe.icc.enum
com.adobe.icc.external.dc
com.adobe.icc.obj
com.adobe.icc.services
com.adobe.icc.services.category
com.adobe.icc.services.config
com.adobe.icc.services.download
com.adobe.icc.services.export
com.adobe.icc.services.external
com.adobe.icc.services.formbridge
com.adobe.icc.services.fragmentlayout
com.adobe.icc.services.layout
com.adobe.icc.services.letter
com.adobe.icc.services.locator
com.adobe.icc.services.module
com.adobe.icc.services.render
com.adobe.icc.services.submit
com.adobe.icc.services.user
com.adobe.icc.token
com.adobe.icc.vo
com.adobe.icc.vo.render
com.adobe.icomm.assetplacement.controller
com.adobe.icomm.assetplacement.controller.utils
com.adobe.icomm.assetplacement.data
com.adobe.icomm.assetplacement.model
com.adobe.livecycle.assetmanager.client
com.adobe.livecycle.assetmanager.client.event
com.adobe.livecycle.assetmanager.client.handler
com.adobe.livecycle.assetmanager.client.managers
com.adobe.livecycle.assetmanager.client.model
com.adobe.livecycle.assetmanager.client.model.cms
com.adobe.livecycle.assetmanager.client.service
com.adobe.livecycle.assetmanager.client.service.search
com.adobe.livecycle.assetmanager.client.service.search.cms
com.adobe.livecycle.assetmanager.client.utils
com.adobe.livecycle.content
com.adobe.livecycle.rca.model
com.adobe.livecycle.rca.model.constant
com.adobe.livecycle.rca.model.document
com.adobe.livecycle.rca.model.participant
com.adobe.livecycle.rca.model.reminder
com.adobe.livecycle.rca.model.stage
com.adobe.livecycle.rca.service
com.adobe.livecycle.rca.service.core
com.adobe.livecycle.rca.service.core.delegate
com.adobe.livecycle.rca.service.process
com.adobe.livecycle.rca.service.process.delegate
com.adobe.livecycle.rca.token
com.adobe.livecycle.ria.security.api
com.adobe.livecycle.ria.security.service
com.adobe.mosaic.layouts
com.adobe.mosaic.layouts.dragAndDrop
com.adobe.mosaic.layouts.interfaces
com.adobe.mosaic.mxml
com.adobe.mosaic.om.constants
com.adobe.mosaic.om.events
com.adobe.mosaic.om.impl
com.adobe.mosaic.om.interfaces
com.adobe.mosaic.skinning
com.adobe.mosaic.sparklib.editors
com.adobe.mosaic.sparklib.optionMenu
com.adobe.mosaic.sparklib.scrollableMenu
com.adobe.mosaic.sparklib.scrollableMenu.skins
com.adobe.mosaic.sparklib.tabLayout
com.adobe.mosaic.sparklib.tabLayout.events
com.adobe.mosaic.sparklib.tabLayout.layouts
com.adobe.mosaic.sparklib.tabLayout.skins
com.adobe.mosaic.sparklib.text
com.adobe.mosaic.sparklib.util
com.adobe.solutions.acm.authoring.presentation
com.adobe.solutions.acm.authoring.presentation.actionbar
com.adobe.solutions.acm.authoring.presentation.common
com.adobe.solutions.acm.authoring.presentation.events
com.adobe.solutions.acm.authoring.presentation.fragment
com.adobe.solutions.acm.authoring.presentation.letter
com.adobe.solutions.acm.authoring.presentation.letter.data
com.adobe.solutions.acm.authoring.presentation.preview
com.adobe.solutions.acm.authoring.presentation.rte
com.adobe.solutions.acm.ccr.presentation
com.adobe.solutions.acm.ccr.presentation.contentcapture
com.adobe.solutions.acm.ccr.presentation.contentcapture.events
com.adobe.solutions.acm.ccr.presentation.contentcapture.preview
com.adobe.solutions.acm.ccr.presentation.datacapture
com.adobe.solutions.acm.ccr.presentation.datacapture.renderers
com.adobe.solutions.acm.ccr.presentation.pdf
com.adobe.solutions.exm
com.adobe.solutions.exm.authoring
com.adobe.solutions.exm.authoring.components.controls
com.adobe.solutions.exm.authoring.components.toolbars
com.adobe.solutions.exm.authoring.domain
com.adobe.solutions.exm.authoring.domain.expression
com.adobe.solutions.exm.authoring.domain.impl
com.adobe.solutions.exm.authoring.domain.method
com.adobe.solutions.exm.authoring.domain.variable
com.adobe.solutions.exm.authoring.enum
com.adobe.solutions.exm.authoring.events
com.adobe.solutions.exm.authoring.model
com.adobe.solutions.exm.authoring.renderer
com.adobe.solutions.exm.authoring.view
com.adobe.solutions.exm.expression
com.adobe.solutions.exm.impl
com.adobe.solutions.exm.impl.method
com.adobe.solutions.exm.method
com.adobe.solutions.exm.mock
com.adobe.solutions.exm.mock.method
com.adobe.solutions.exm.runtime
com.adobe.solutions.exm.runtime.impl
com.adobe.solutions.exm.variable
com.adobe.solutions.prm.constant
com.adobe.solutions.prm.domain
com.adobe.solutions.prm.domain.factory
com.adobe.solutions.prm.domain.impl
com.adobe.solutions.prm.domain.manager
com.adobe.solutions.prm.presentation.asset
com.adobe.solutions.prm.presentation.constant
com.adobe.solutions.prm.presentation.document
com.adobe.solutions.prm.presentation.event
com.adobe.solutions.prm.presentation.file
com.adobe.solutions.prm.presentation.project
com.adobe.solutions.prm.presentation.team
com.adobe.solutions.prm.presentation.util
com.adobe.solutions.prm.service
com.adobe.solutions.prm.services.impl
com.adobe.solutions.prm.vo
com.adobe.solutions.rca.constant
com.adobe.solutions.rca.domain
com.adobe.solutions.rca.domain.common
com.adobe.solutions.rca.domain.factory
com.adobe.solutions.rca.domain.impl
com.adobe.solutions.rca.domain.impl.manager
com.adobe.solutions.rca.domain.manager
com.adobe.solutions.rca.presentation
com.adobe.solutions.rca.presentation.comment
com.adobe.solutions.rca.presentation.constant
com.adobe.solutions.rca.presentation.event
com.adobe.solutions.rca.presentation.gantt
com.adobe.solutions.rca.presentation.gantt.ruler
com.adobe.solutions.rca.presentation.template
com.adobe.solutions.rca.presentation.template.audit
com.adobe.solutions.rca.presentation.template.definition
com.adobe.solutions.rca.presentation.template.documents
com.adobe.solutions.rca.presentation.template.stages
com.adobe.solutions.rca.presentation.util
com.adobe.solutions.rca.service
com.adobe.solutions.rca.services.impl
com.adobe.solutions.rca.vo
com.adobe.solutions.rca.vo.um
com.adobe.viewsource
fl.accessibility
fl.containers
fl.controls
fl.controls.dataGridClasses
fl.controls.listClasses
fl.controls.progressBarClasses
fl.core
fl.data
fl.display
fl.events
fl.ik
fl.lang
fl.livepreview
fl.managers
fl.motion
fl.motion.easing
fl.rsl
fl.text
fl.transitions
fl.transitions.easing
fl.video
flash.accessibility
flash.concurrent
flash.crypto
flash.data
flash.desktop
flash.display
flash.display3D
flash.display3D.textures
flash.errors
flash.events
flash.external
flash.filesystem
flash.filters
flash.geom
flash.globalization
flash.html
flash.media
flash.net
flash.net.dns
flash.net.drm
flash.notifications
flash.permissions
flash.printing
flash.profiler
flash.sampler
flash.security
flash.sensors
flash.system
flash.text
flash.text.engine
flash.text.ime
flash.ui
flash.utils
flash.xml
flashx.textLayout
flashx.textLayout.compose
flashx.textLayout.container
flashx.textLayout.conversion
flashx.textLayout.edit
flashx.textLayout.elements
flashx.textLayout.events
flashx.textLayout.factory
flashx.textLayout.formats
flashx.textLayout.operations
flashx.textLayout.utils
flashx.undo
ga.controls
ga.layouts
ga.model
ga.uiComponents
ga.util
ga.views
ga.wrappers
lc.foundation
lc.foundation.domain
lc.foundation.events
lc.foundation.ui
lc.foundation.util
lc.preloader
lc.procmgmt
lc.procmgmt.commands
lc.procmgmt.domain
lc.procmgmt.events
lc.procmgmt.formbridge
lc.procmgmt.impl
lc.procmgmt.ui.attachments
lc.procmgmt.ui.controls
lc.procmgmt.ui.controls.card
lc.procmgmt.ui.controls.renderer
lc.procmgmt.ui.help
lc.procmgmt.ui.layout
lc.procmgmt.ui.presentationmodel
lc.procmgmt.ui.process
lc.procmgmt.ui.search
lc.procmgmt.ui.startpoint
lc.procmgmt.ui.task
lc.procmgmt.ui.task.form
lc.procmgmt.ui.task.form.commands
lc.procmgmt.ui.tracking
mx.accessibility
mx.automation
mx.automation.air
mx.automation.delegates
mx.automation.delegates.advancedDataGrid
mx.automation.delegates.charts
mx.automation.delegates.containers
mx.automation.delegates.controls
mx.automation.delegates.controls.dataGridClasses
mx.automation.delegates.controls.fileSystemClasses
mx.automation.delegates.core
mx.automation.delegates.flashflexkit
mx.automation.events
mx.binding
mx.binding.utils
mx.charts
mx.charts.chartClasses
mx.charts.effects
mx.charts.effects.effectClasses
mx.charts.events
mx.charts.renderers
mx.charts.series
mx.charts.series.items
mx.charts.series.renderData
mx.charts.styles
mx.collections
mx.collections.errors
mx.containers
mx.containers.accordionClasses
mx.containers.dividedBoxClasses
mx.containers.errors
mx.containers.utilityClasses
mx.controls
mx.controls.advancedDataGridClasses
mx.controls.dataGridClasses
mx.controls.listClasses
mx.controls.menuClasses
mx.controls.olapDataGridClasses
mx.controls.scrollClasses
mx.controls.sliderClasses
mx.controls.textClasses
mx.controls.treeClasses
mx.controls.videoClasses
mx.core
mx.core.windowClasses
mx.data
mx.data.crypto
mx.data.errors
mx.data.events
mx.data.messages
mx.data.mxml
mx.data.offline.errors
mx.data.utils
mx.effects
mx.effects.easing
mx.effects.effectClasses
mx.events
mx.filters
mx.flash
mx.formatters
mx.geom
mx.graphics
mx.graphics.codec
mx.graphics.shaderClasses
mx.logging
mx.logging.errors
mx.logging.targets
mx.managers
mx.messaging
mx.messaging.channels
mx.messaging.config
mx.messaging.errors
mx.messaging.events
mx.messaging.management
mx.messaging.messages
mx.modules
mx.netmon
mx.olap
mx.olap.aggregators
mx.preloaders
mx.printing
mx.resources
mx.rpc
mx.rpc.events
mx.rpc.http
mx.rpc.http.mxml
mx.rpc.livecycle
mx.rpc.mxml
mx.rpc.remoting
mx.rpc.remoting.mxml
mx.rpc.soap
mx.rpc.soap.mxml
mx.rpc.wsdl
mx.rpc.xml
mx.skins
mx.skins.halo
mx.skins.spark
mx.skins.wireframe
mx.skins.wireframe.windowChrome
mx.states
mx.styles
mx.utils
mx.validators
org.osmf.containers
org.osmf.display
org.osmf.elements
org.osmf.events
org.osmf.layout
org.osmf.logging
org.osmf.media
org.osmf.metadata
org.osmf.net
org.osmf.net.dvr
org.osmf.net.httpstreaming
org.osmf.net.metrics
org.osmf.net.qos
org.osmf.net.rtmpstreaming
org.osmf.net.rules
org.osmf.traits
org.osmf.utils
spark.accessibility
spark.automation.delegates
spark.automation.delegates.components
spark.automation.delegates.components.gridClasses
spark.automation.delegates.components.mediaClasses
spark.automation.delegates.components.supportClasses
spark.automation.delegates.skins.spark
spark.automation.events
spark.collections
spark.components
spark.components.calendarClasses
spark.components.gridClasses
spark.components.mediaClasses
spark.components.supportClasses
spark.components.windowClasses
spark.core
spark.effects
spark.effects.animation
spark.effects.easing
spark.effects.interpolation
spark.effects.supportClasses
spark.events
spark.filters
spark.formatters
spark.formatters.supportClasses
spark.globalization
spark.globalization.supportClasses
spark.layouts
spark.layouts.supportClasses
spark.managers
spark.modules
spark.preloaders
spark.primitives
spark.primitives.supportClasses
spark.skins
spark.skins.mobile
spark.skins.mobile.supportClasses
spark.skins.spark
spark.skins.spark.mediaClasses.fullScreen
spark.skins.spark.mediaClasses.normal
spark.skins.spark.windowChrome
spark.skins.wireframe
spark.skins.wireframe.mediaClasses
spark.skins.wireframe.mediaClasses.fullScreen
spark.transitions
spark.utils
spark.validators
spark.validators.supportClasses
xd.core.axm.enterprise.view.components
xd.core.axm.enterprise.view.skins
xd.core.axm.view.components
xd.core.axm.view.components.support

Language Elements

Global Constants
Global Functions
Operators
Statements, Keywords & Directives
Special Types

Appendixes

What's New
Compiler Errors
Compiler Warnings
Run-Time Errors
Migrating to ActionScript 3
Supported Character Sets
MXML Only Tags
Motion XML Elements
Timed Text Tags
List of deprecated elements
Accessibility Implementation Constants
How to Use ActionScript Examples
Legal notices
Packageflash.globalization
Classpublic final class DateTimeFormatter
InheritanceDateTimeFormatter Inheritance Object

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

View the examples

Related API Elements



Public Properties
 PropertyDefined By
  actualLocaleIDName : String
[read-only] The name of the actual locale ID used by this DateTimeFormatter object.
DateTimeFormatter
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  lastOperationStatus : String
[read-only] The status of previous operation that this DateTimeFormatter object performed.
DateTimeFormatter
  requestedLocaleIDName : String
[read-only] The name of the requested locale ID that was passed to the constructor of this DateTimeFormatter object.
DateTimeFormatter
Public Methods
 MethodDefined By
  
DateTimeFormatter(requestedLocaleIDName:String, dateStyle:String = "long", timeStyle:String = "long")
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.
DateTimeFormatter
  
format(dateTime:Date):String
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).
DateTimeFormatter
  
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.
DateTimeFormatter
  
[static] Lists all of the locale ID names supported by this class.
DateTimeFormatter
  
Gets the date style for this instance of the DateTimeFormatter.
DateTimeFormatter
  
Returns the pattern string used by this DateTimeFormatter object to format dates and times.
DateTimeFormatter
  
Returns an integer corresponding to the first day of the week for this locale and calendar system.
DateTimeFormatter
  
getMonthNames(nameStyle:String = "full", context:String = "standalone"):Vector.<String>
Retrieves a list of localized strings containing the month names for the current calendar system.
DateTimeFormatter
  
Gets the time style for this instance of the DateTimeFormatter.
DateTimeFormatter
  
getWeekdayNames(nameStyle:String = "full", context:String = "standalone"):Vector.<String>
Retrieves a list of localized strings containing the names of weekdays for the current calendar system.
DateTimeFormatter
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
  
Sets the pattern string used by this DateTimeFormatter object to format dates and times.
DateTimeFormatter
  
setDateTimeStyles(dateStyle:String, timeStyle:String):void
Sets the date and time styles for this instance of the DateTimeFormatter.
DateTimeFormatter
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property Detail

actualLocaleIDName

property
actualLocaleIDName:String  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.
  3. If the system does not support the requestedLocaleIDName specified in the constructor then a fallback locale ID name is provided.



Implementation
    public function get actualLocaleIDName():String

Related API Elements

lastOperationStatus

property 
lastOperationStatus:String  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.



Implementation
    public function get lastOperationStatus():String

Related API Elements

requestedLocaleIDName

property 
requestedLocaleIDName:String  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.



Implementation
    public function get requestedLocaleIDName():String

Related API Elements

Constructor Detail

DateTimeFormatter

()Constructor
public function DateTimeFormatter(requestedLocaleIDName:String, dateStyle:String = "long", timeStyle:String = "long")

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

Parameters
requestedLocaleIDName:String — The preferred locale ID name to use when determining date or time formats.
 
dateStyle:String (default = "long") — Specifies 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
 
timeStyle:String (default = "long") — Specifies 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

Throws
ArgumentError — if the dateStyle or timeStyle parameter is not a valid DateTimeStyle constant.
 
TypeError — if the dateStyle or timeStyle parameter is null.

Related API Elements

Method Detail

format

()method
public function format(dateTime:Date):String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

Parameters

dateTime:Date — A Date value to be formatted. Valid range is from Jan 1, 1601 to Dec 31, 30827.

Returns
String — A formatted string representing the date or time value.

Related API Elements

formatUTC

()method 
public function formatUTC(dateTime:Date):String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

Parameters

dateTime:Date — A Date value to be formatted. Valid range is from Jan 1, 1601 to Dec 31, 30827.

Returns
String — A formatted string representing the date or time value.

Related API Elements

getAvailableLocaleIDNames

()method 
public static function getAvailableLocaleIDNames():Vector.<String>

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

Returns
Vector.<String> — A vector of strings containing all of the locale ID names supported by this class.

Related API Elements

getDateStyle

()method 
public function getDateStyle():String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

Returns
String — The date style string for this formatter.

Possible values:

  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE
  • DateTimeStyle.CUSTOM

Related API Elements

getDateTimePattern

()method 
public function getDateTimePattern():String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

Returns
String — A string containing the pattern used by this DateTimeFormatter object to format dates and times.

Related API Elements

getFirstWeekday

()method 
public function getFirstWeekday():int

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

Returns
int — An integer corresponding to the first day of the week for this locale and calendar system.

Related API Elements

getMonthNames

()method 
public function getMonthNames(nameStyle:String = "full", context:String = "standalone"):Vector.<String>

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

Parameters

nameStyle:String (default = "full") — Indicates the style of name string to be used. Valid values are:
  • DateTimeNameStyle.FULL
  • DateTimeNameStyle.LONG_ABBREVIATION
  • DateTimeNameStyle.SHORT_ABBREVIATION
 
context:String (default = "standalone") — A 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

Returns
Vector.<String> — A 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.

Throws
TypeError — if the nameStyle or context parameter is null.

Related API Elements

getTimeStyle

()method 
public function getTimeStyle():String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

Returns
String — The time style string for this formatter.

Possible values:

  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE
  • DateTimeStyle.CUSTOM

Related API Elements

getWeekdayNames

()method 
public function getWeekdayNames(nameStyle:String = "full", context:String = "standalone"):Vector.<String>

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

Parameters

nameStyle:String (default = "full") — Indicates the style of name string to be used. Valid values are:
  • DateTimeNameStyle.FULL
  • DateTimeNameStyle.LONG_ABBREVIATION
  • DateTimeNameStyle.SHORT_ABBREVIATION
 
context:String (default = "standalone") — A 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

Returns
Vector.<String> — A 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.

Throws
TypeError — if the nameStyle or context parameter is null.

Related API Elements

setDateTimePattern

()method 
public function setDateTimePattern(pattern:String):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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 letterDescription
GEra. 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.

Parameters

pattern:String


Throws
TypeError — if the pattern parameter is null.

Related API Elements

setDateTimeStyles

()method 
public function setDateTimeStyles(dateStyle:String, timeStyle:String):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.1, AIR 2

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.

Parameters

dateStyle:String — Specifies 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
 
timeStyle:String — Specifies 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


Throws
ArgumentError — if the dateStyle or timeStyle parameter is not a valid DateTimeStyle constant.
 
TypeError — if the dateStyle or timeStyle parameter is null.

Related API Elements

DateTimeFormatter.1.as

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() + ")");
            }        
        }
    }
}
DateTimeFormatter.2.as

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();    
        }
    }
}