用于 Adobe® Flash® Platform 的 ActionScript® 3.0 参考
主页  |  隐藏包列表和类列表 |   |   |  新增内容  |  索引  |  附录  |  为什么显示为英语?
过滤条件: AIR 30.0 和更早版本, Flash Player 30.0 和更早版本, Flash Lite 4
Flex 4.6 和更早版本, Flash Pro CS6 和更早版本
隐藏过滤条件
flash.globalization 

DateTimeFormatter  - AS3

x

顶级
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

语言元素

全局常量
全局函数
运算符
语句、关键字和指令
特殊类型

附录

新增内容
编译器错误
编译器警告
运行时错误
迁移到 ActionScript 3
支持的字符集
仅适用于 MXML 的标签
Motion XML 元素
Timed Text 标记
不推荐使用的元素的列表
AccessibilityImplementation 常量
如何使用 ActionScript 示例
法律声明
flash.globalization
public final class DateTimeFormatter
继承DateTimeFormatter Inheritance Object

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

DateTimeFormatter 类为 Date 对象提供区分区域设置的格式设置并提供对本地化日期字段名的访问权限。此类的方法使用操作系统提供的函数和设置。

有两种选择日期时间格式的方法:使用预定义模式或自定模式。对于大多数应用程序,应该使用由 DateTimeStyle 常量 (LONGMEDIUMNONESHORT 指定的预定义样式。这些常量指定请求的区域设置的默认模式或指定基于用户操作系统设置的默认模式。

例如,以下代码使用默认短日期格式创建日期字符串:

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

创建此类的实例后,如果操作系统支持请求的区域设置,则根据请求的区域设置的约定和默认值以及构造函数的 dateStyletimeStyle 参数设置该实例的属性。如果请求的区域设置不可用,则根据回退或默认系统区域设置来设置属性,可以使用 actualLocaleIDName 属性检索默认系统区域设置。

此类包含其他方法,用于获得月名称和工作日名称的本地化字符串,以及检索可在日历选取器或其他类似应用程序中使用的每周第一天。

由于使用用户的设置、使用操作系统提供的格式设置模式,并在请求的区域设置不受支持时使用回退区域设置,因此,即便使用相同的区域设置 ID,对不同的用户显示的格式设置结果也可能不同。

查看示例

相关 API 元素



公共属性
 属性由以下参数定义
  actualLocaleIDName : String
[只读] 此 DateTimeFormatter 对象使用的实际区域设置 ID 的名称。
DateTimeFormatter
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
  lastOperationStatus : String
[只读] 此 DateTimeFormatter 对象执行的前一操作的状态。
DateTimeFormatter
  requestedLocaleIDName : String
[只读] 传递到此 DateTimeFormatter 对象的构造函数的请求区域设置 ID 的名称。
DateTimeFormatter
公共方法
 方法由以下参数定义
  
DateTimeFormatter(requestedLocaleIDName:String, dateStyle:String = "long", timeStyle:String = "long")
构造新 DateTimeFormatter 对象,以根据指定区域设置的约定以及提供的日期和时间格式设置样式来设置日期和时间的格式。
DateTimeFormatter
  
format(dateTime:Date):String
设置解释为以用户本地时间表示(使用 Date 对象的本地时间组件,如 date、day、fullYear、hours、minutes、month 和 seconds)的 Date 对象的显示字符串的格式。
DateTimeFormatter
  
根据 dateStyle、timeStyle 或日期时间模式,设置解释为以 UTC 时间表示(使用 Date 对象的 UTC 组成组件,如 dateUTC、dayUTC、fullYearUTC、hoursUTC、minutesUTC、monthUTC 和 secondsUTC)的 Date 对象的显示字符串的格式。
DateTimeFormatter
  
[静态] 列出此类支持的所有区域设置 ID 名称。
DateTimeFormatter
  
获取此实例 DateTimeFormatter 的日期样式。
DateTimeFormatter
  
返回此 DateTimeFormatter 对象设置日期和时间格式所用的模式字符串。
DateTimeFormatter
  
返回一个整数,它对应于此区域设置和日历系统的每周第一天。
DateTimeFormatter
  
getMonthNames(nameStyle:String = "full", context:String = "standalone"):Vector.<String>
检索包含当前日历系统的月名称的本地化字符串列表。
DateTimeFormatter
  
获取此实例 DateTimeFormatter 的时间样式。
DateTimeFormatter
  
getWeekdayNames(nameStyle:String = "full", context:String = "standalone"):Vector.<String>
检索包含当前日历系统的工作日名称的本地化字符串列表。
DateTimeFormatter
 Inherited
表示对象是否已经定义了指定的属性。
Object
 Inherited
表示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
表示指定的属性是否存在、是否可枚举。
Object
  
设置此 DateTimeFormatter 对象设置日期和时间格式所用的模式字符串。
DateTimeFormatter
  
setDateTimeStyles(dateStyle:String, timeStyle:String):void
设置此 DateTimeFormatter 实例的日期和时间样式。
DateTimeFormatter
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。
Object
 Inherited
返回指定对象的字符串表示形式。
Object
 Inherited
返回指定对象的原始值。
Object
属性详细信息

actualLocaleIDName

属性
actualLocaleIDName:String  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

此 DateTimeFormatter 对象使用的实际区域设置 ID 的名称。

根据操作系统和传递给 Collator() 构造函数的 requestedLocaleIDName 参数的值,该名称有三种可能的值。

  1. 如果请求的区域设置不是 LocaleID.DEFAULT 且操作系统支持该请求的区域设置,则返回的名称与 requestedLocaleIDName 属性相同。
  2. 如果将 LocaleID.DEFAULT 用作构造函数的 requestedLocaleIDName 参数的值,则使用由用户操作系统指定的当前区域设置的名称。LocaleID.DEFAULT 值保留用户在操作系统中的自定义设置。显式值作为 requestedLocaleIDName 参数传递与使用 LocaleID.DEFAULT 所产生的结果不一定相同,即使两个区域设置 ID 名称相同,也是如此。用户可能已在他们的计算机上对区域设置进行了自定义,通过请求显式区域设置 ID 名称(而不是使用 LocaleID.DEFAULT),您的应用程序将不会检索这些自定义设置。
  3. 如果系统不支持在构造函数中指定的 requestedLocaleIDName,则会提供回退区域设置 ID 名称。



实现
    public function get actualLocaleIDName():String

相关 API 元素

lastOperationStatus

属性 
lastOperationStatus:String  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

此 DateTimeFormatter 对象执行的前一操作的状态。只要调用构造函数或此类的方法或设置另一个属性,就会设置 lastOperationStatus 属性。有关可能的值,请参阅每种方法的说明。



实现
    public function get lastOperationStatus():String

相关 API 元素

requestedLocaleIDName

属性 
requestedLocaleIDName:String  [只读]

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

传递到此 DateTimeFormatter 对象的构造函数的请求区域设置 ID 的名称。

如果使用了 LocaleID.DEFAULT 值,则返回的名称将是“i-default”。如果应用了回退区域设置,则实际使用的区域设置可能与请求的区域设置不同。可以使用 actualLocaleIDName 属性检索实际区域设置的名称。



实现
    public function get requestedLocaleIDName():String

相关 API 元素

构造函数详细信息

DateTimeFormatter

()构造函数
public function DateTimeFormatter(requestedLocaleIDName:String, dateStyle:String = "long", timeStyle:String = "long")

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

构造新 DateTimeFormatter 对象,以根据指定区域设置的约定以及提供的日期和时间格式设置样式来设置日期和时间的格式。日期和时间样式用于将日期和时间格式设置模式设置为操作系统中预定义的与区域设置相关的模式。

此构造函数确定当前操作系统是否支持请求的区域设置 ID 名称。如果不支持,则使用回退区域设置。回退区域设置 ID 的名称可通过 actualLocaleIDName 属性确定。

如果回退用于任何 requestedLocaleIDNamedateStyletimeStyle 参数,则会设置 lastOperationStatus 属性来表示回退类型。

要根据用户的当前操作系统首选项进行格式设置,请将 requestedLocaleIDName 参数中的值 LocaleID.DEFAULT 传递给构造函数。

调用构造函数并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

如果请求的区域设置 ID 名称不可用,则将 lastOperationStatus 属性设置为下列属性之一:

  • LastOperationStatus.USING_FALLBACK_WARNING
  • LastOperationStatus.USING_DEFAULT_WARNING

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的其中一个常量。

有关以上列出的警告和 lastOperationStatus 属性其他可能值的详细信息,请参阅 LastOperationStatus 类中的说明。

参数
requestedLocaleIDName:String — 确定日期或时间格式时使用的首选区域设置 ID 名称。
 
dateStyle:String (default = "long") — 指定设置日期格式时使用的样式。此值对应于由 DateTimeStyle 类枚举的一个值:
  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE
 
timeStyle:String (default = "long") — 指定设置时间格式时使用的样式。此值对应于由 DateTimeStyle 类枚举的一个值:
  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE

引发
ArgumentError — 如果 dateStyletimeStyle 参数不是有效的 DateTimeStyle 常量。
 
TypeError — 如果 dateStyletimeStyle 参数为 null。

相关 API 元素

方法详细信息

format

()方法
public function format(dateTime:Date):String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

设置解释为以用户本地时间表示(使用 Date 对象的本地时间组件,如 date、day、fullYear、hours、minutes、month 和 seconds)的 Date 对象的显示字符串的格式。将使用为此 DateTimeFormatter 实例指定的区域设置 ID 的约定和日期样式及时间样式或者自定义的日期模式和时间模式来完成格式设置。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

参数

dateTime:Date — 要设置格式的 Date 值。有效范围为 1601 年 1 月 1 日至 30827 年 12 月 31 日。

返回
String — 表示日期或时间值的设置了格式的字符串。

相关 API 元素

formatUTC

()方法 
public function formatUTC(dateTime:Date):String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

根据 dateStyle、timeStyle 或日期时间模式,设置解释为以 UTC 时间表示(使用 Date 对象的 UTC 组成组件,如 dateUTC、dayUTC、fullYearUTC、hoursUTC、minutesUTC、monthUTC 和 secondsUTC)的 Date 对象的显示字符串的格式。将使用为此 DateTimeFormatter 实例指定的区域设置 ID 的约定和日期样式及时间样式或者自定义的日期模式和时间模式来完成格式设置。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

参数

dateTime:Date — 要设置格式的 Date 值。有效范围为 1601 年 1 月 1 日至 30827 年 12 月 31 日。

返回
String — 表示日期或时间值的设置了格式的字符串。

相关 API 元素

getAvailableLocaleIDNames

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

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

列出此类支持的所有区域设置 ID 名称。

如果当前操作系统不支持此类,此方法返回 null 值。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

返回
Vector.<String> — 一个字符串矢量,其中包含此类支持的所有区域设置 ID 名称。

相关 API 元素

getDateStyle

()方法 
public function getDateStyle():String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

获取此实例 DateTimeFormatter 的日期样式。日期样式用于从操作系统检索预定义的日期格式设置模式。可通过 DateTimeFormatter() 构造函数、setDateTimeStyles() 方法或 setDateTimePattern() 方法设置日期样式值。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

返回
String — 此格式程序的日期样式字符串。

可能的值:

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

相关 API 元素

getDateTimePattern

()方法 
public function getDateTimePattern():String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

返回此 DateTimeFormatter 对象设置日期和时间格式所用的模式字符串。

可以使用以下三种方法之一设置此模式:

  1. 通过构造函数中使用的 dateStyletimeStyle 参数。
  2. 通过 setDateTimeStyles() 方法。
  3. 通过 setDateTimePattern() 方法。

有关模式语法的说明,请参阅 setDateTimePattern() 方法。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

返回
String — 一个字符串,其中包含此 DateTimeFormatter 对象设置日期和时间格式所用的模式。

相关 API 元素

getFirstWeekday

()方法 
public function getFirstWeekday():int

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

返回一个整数,它对应于此区域设置和日历系统的每周第一天。值 0 对应于星期日,1 对应于星期一,依此类推,6 对应于星期六。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

返回
int — 一个整数,对应于此区域设置和日历系统的每周第一天。

相关 API 元素

getMonthNames

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

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

检索包含当前日历系统的月名称的本地化字符串列表。列表中的第一个元素表示一年中第一个月的名称。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

参数

nameStyle:String (default = "full") — 表示要使用的名称字符串样式。有效值为:
  • DateTimeNameStyle.FULL
  • DateTimeNameStyle.LONG_ABBREVIATION
  • DateTimeNameStyle.SHORT_ABBREVIATION
 
context:String (default = "standalone") — 一个代码,表示在其中使用设置了格式的字符串的上下文。此上下文仅对于某些区域设置不同。有效值为:
  • DateTimeNameContext.FORMAT
  • DateTimeNameContext.STANDALONE

返回
Vector.<String> — 一个本地化字符串矢量,其中包含指定区域设置、名称样式和上下文的月名称。矢量中位于索引 0 处的第一个元素表示一年中第一个月的名称;下一个元素表示一年中第二个月的名称;以此类推。

引发
TypeError — 如果 nameStylecontext 参数为 null。

相关 API 元素

getTimeStyle

()方法 
public function getTimeStyle():String

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

获取此实例 DateTimeFormatter 的时间样式。时间样式用于从操作系统检索预定义的时间格式设置模式。可通过 DateTimeFormatter() 构造函数、setDateTimeStyles() 方法或 setDateTimePattern() 方法设置时间样式值。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

返回
String — 此格式程序的时间样式字符串。

可能的值:

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

相关 API 元素

getWeekdayNames

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

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

检索包含当前日历系统的工作日名称的本地化字符串列表。列表中的第一个元素表示星期日的名称。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

参数

nameStyle:String (default = "full") — 表示要使用的名称字符串样式。有效值为:
  • DateTimeNameStyle.FULL
  • DateTimeNameStyle.LONG_ABBREVIATION
  • DateTimeNameStyle.SHORT_ABBREVIATION
 
context:String (default = "standalone") — 一个代码,表示在其中使用设置了格式的字符串的上下文。该上下文仅适用于月份名称随上下文变化的特定区域设置。例如,在希腊语中,月份名称单独显示时同与日一起显示时不同。有效值为:
  • DateTimeNameContext.FORMAT
  • DateTimeNameContext.STANDALONE

返回
Vector.<String> — 一个本地化字符串矢量,其中包含指定区域设置、名称样式和上下文的月名称。矢量中位于索引 0 处的第一个元素是星期日的名称;下一个元素是星期一的名称;依此类推。

引发
TypeError — 如果 nameStylecontext 参数为 null。

相关 API 元素

setDateTimePattern

()方法 
public function setDateTimePattern(pattern:String):void

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

设置此 DateTimeFormatter 对象设置日期和时间格式所用的模式字符串。

可通过以下三种方法之一设置用于对日期进行格式设置的模式:

  1. 通过构造函数中使用的 dateStyletimeStyle 参数。
  2. 通过 setDateTimeStyles() 方法。
  3. 通过 setDateTimePattern() 方法。

使用此方法的另一结果是:将覆盖此 DateTimeFormatter 对象的当前时间和日期样式,并将其值设置为 DateTimeStyle.CUSTOM

用于定义如何设置日期和时间格式的模式字符串。模式包含一系列将设置了格式的字符串中的日期和时间值替换的字母。例如,在“yyyy/MM”模式中,字符“yyyy”被四位数字的年份替换,它后面跟“/”字符,字符“MM”被两位数字的月份替换。

模式中所用的许多字符都可以重复使用多次以产生不同的输出,如下表所示。

如果序列超过了模式支持的最大字母数,则会将该序列映射回所支持的该模式字母的最长序列。例如:

  • MMMMMM 被替换为 MMMM
  • dddd 被替换为 dd
  • EEEEEEE 被替换为 EEEE
  • aa 被替换为 a
  • hhh 被替换为 hh
  • mmmm 被替换为 mm

从理论上说,一个模式最多可包含 255 个字符,但某些平台具有更严格的限制。如果模式超过了模式字符限制,则 lastOperationStatus 属性的值将被设置为 LastOperationStatus.PATTERN_SYNTAX_ERROR

并不是每一个操作系统都支持所有可能的模式。如果平台不支持某一种模式,则使用回退模式,并设置 lastOperationStatus 属性表示使用回退模式。如果未提供合理的回退模式,则使用空字符串,并设置 lastOperationStatus 属性表示不支持该模式。

下表列出了有效的模式字母以及它们的含义。

模式字母说明
G纪元。由当前日期和日历的纪元字符串替换。并非所有操作系统都支持此模式。在不支持纪元的操作系统上,输入模式的字母被空字符串替换。

纪元模式中可以包含一到五个字母,具体解释如下:

  • 如果有一到三个模式字母,则将使用缩写格式。
  • 如果有四个模式字母,则格式将设置为完整形式。
  • 如果有五个模式字母,则格式将设置为短缩写形式。

有关公历(对于支持此模式的操作系统)的示例:

  • G, GG, GGG = AD
  • GGGG = Anno Domini
  • GGGGG = A
y年份。如果有两个模式字母,则显示年份的最后两位数字;否则由字母数目确定要显示的数字位数。如果年份值要求显示的数字位数多于字母数目提供的位数,则将提供完整的年份值。如果年份值要求的值少于字母数目,则将用 0 来填充年份值。下面的列表显示了 1 到 2005 年份值的结果。

示例:

  • y = 1
  • y = 2005
  • yy = 01
  • yy = 05
  • yyyy = 0001 或 01,具体取决于操作系统。
  • yyyy = 2005
  • yyyyy = 01 或 0001,具体取决于操作系统。超过 4 的年份值位数回退到操作系统支持的最大数字位数。
  • yyyyy = 2005
M 一年中的月份。月份模式中可以包含一到五个字母,具体设置如下:
  • 如果有一个模式字母,则格式将设置为一位或两位数值。
  • 如果有两个模式字母,则格式将设置为两位数值。
  • 如果有三个模式字母,则格式将设置为长缩写形式。
  • 如果有四个模式字母,则格式将解释为完整名称。
  • 如果有五个模式字母,则格式将设置为短缩写形式。并非所有操作系统都支持此格式,将回退到长缩写形式。

示例:

  • M = 7
  • MM = 07
  • MMM = Jul,7月
  • MMMM = July,7月
  • MMMMM = J 或 Jul,7 或 7月,具体取决于操作系统。
d 一个月中的某一天。月中某天模式中可以包含一个或两个字母,具体设置如下:
  • 如果有一个模式字母,则格式将设置为一位或两位数值。
  • 如果有两个模式字母,则格式将设置为两位数值。

示例:

  • d = 4
  • dd = 04
  • dd = 14
E星期中的天。星期中某天模式中可以包含一到五个字母,具体设置如下:
  • 如果有三个模式字母,则格式将设置为长缩写形式。
  • 如果有四个模式字母,则格式将解释为完整名称。
  • 如果有五个模式字母,则格式将设置为短缩写形式。并非所有操作系统都支持此格式,将回退到长缩写形式。

示例:

  • E,EE,EEE = Tues
  • EEEE = Tuesday
  • EEEEE = T 或 Tues,具体取决于操作系统。
Q季度。某些平台不支持此模式。季度模式中可以包含一到四个字母,具体设置如下:
  • 如果有一个模式字母,则格式将设置为一位数值。
  • 如果有两个模式字母,则格式将设置为两位数值。
  • 如果有三个模式字母,则格式将设置为缩写。
  • 如果有四个模式字母,则格式将解释为完整名称。

示例(对于支持此模式的操作系统):

  • Q = 2
  • QQ = 02
  • QQQ = Q2
  • QQQQ = 第二季度
w一年中的某一周。某些平台不支持此模式。此模式中可以包含一到两个字母,具体设置如下所示。
  • 如果有一个模式字母,则格式将设置为一位或两位数值。
  • 如果有两个模式字母,则格式将设置为两位数值。

以一年的第二周为例(对于支持此模式的操作系统):

  • w = 2
  • ww = 02
W一个月中的某一周。某些平台不支持此模式。此模式只可包含一个字母。

以 7 月的第二周为例(对于支持此模式的操作系统):

  • W = 2
D一年中的某一天。某些平台不支持此模式。此模式中可以包含一到三个字母。

以一年中的第二天为例(对于支持此模式的操作系统):

  • D = 2
  • DD = 02
  • DDD = 002
F日历月中每周第某天的出现次数。例如,如果用来为 10 月份的第三个星期一设置日期格式,此元素显示“3”。此模式只可包含一个字母。

以 7 月份的第二个星期三为例(对于支持此模式的操作系统):

  • F = 2
一个AM/PM 表示器。此模式只可包含一个字母:a 或 p。

示例:

  • a = AM,午前
  • p = PM,午后
h使用 12 小时制的一天中的某个小时 [1 - 12]。此模式必须包含一个或两个字母。

示例:

  • h = 1
  • h = 12
  • hh = 01
H使用 24 小时制的一天中的某个小时 [0 - 23]。此模式必须包含一个或两个字母。

示例:

  • H = 0
  • H = 23
  • HH = 00
K使用 12 小时制的一天中的某个小时 [0 - 11]。此模式必须包含一个或两个字母。并非所有操作系统都支持此模式。

示例(对于支持此模式的操作系统):

  • K = 0
  • K = 11
  • KK = 00
k使用 24 小时制的一天中的某个小时 [1 - 24]。此模式必须包含一个或两个字母。并非所有操作系统都支持此模式。

示例(对于支持此模式的操作系统):

  • k = 1
  • k = 24
  • kk = 01
m小时内第几分钟 [0 - 59]。此模式必须包含一个或两个字母。

示例:

  • m = 2
  • m = 59
  • mm = 02
s分钟内第几秒 [0 - 59]。此模式必须包含一个或两个字母。

示例:

  • s = 2
  • s = 59
  • ss = 02
S毫秒。此模式必须包含一到五个字母。根据使用的字母数对此值进行舍入。当使用五个字符 (SSSSS) 时,它表示毫秒小数。

示例:

  • S = 2
  • SS = 24
  • SSS = 235
  • SSSS = 2350
  • SSSSS = 23500
z时区。将时区表示为相对于标准时间或夏令时(而无需参考特定位置)的字符串。并非所有操作系统都支持此模式。在不支持时区模式的操作系统上,输入模式的字母被空字符串替换。在不支持此模式的操作系统上,并不是所有的区域设置都有定义的字符串。这些区域设置将回退到本地化 GMT 格式,例如 GMT-08:00 或 GW-08:00

此时区模式必须包含一到四个字母,具体设置如下:

  • 如果有一到三个模式字母,则格式将设置为缩写形式。
  • 如果有四个模式字母,则格式将解释为完整名称。

示例(对于支持此格式的操作系统):

  • z,zz,zzz = PDT
  • z,zz,zzz = PST
  • z,zz,zzz = GMT-0800
  • zzzz = 太平洋夏令时
  • zzzz = 太平洋标准时间
Z时区。将时区表示为与 GMT 的偏移。并非所有操作系统都支持此模式。在不支持时区模式的操作系统上,输入模式的字母被空字符串替换。

此时区模式必须包含一到四个字母,具体设置如下:

  • 如果有一到三个模式字母,则格式将使用 RFC 822 格式。
  • 如果有四个模式字母,则格式将使用本地化的 GMT 格式。对于不具有本地化 GMT 格式的区域设置,此模式回退到的未本地化的 GMT 格式。

示例(对于支持此格式的操作系统):

  • Z,ZZ,ZZZ = -0800
  • ZZZZ = GMT-08:00,GW-08:00
v时区。表示不需要参考特定位置或区分夏令时或标准时间的一般时区的字符串。并非所有操作系统都支持此模式。在不支持时区模式的操作系统上,输入模式的字母被空字符串替换。在支持此模式的操作系统上,如果本地化名称不可用,则提供回退字符串。

此时区模式必须包含一个或四个字母,具体设置如下:

  • 如果有一个模式字母,则格式使用缩写形式。
  • 如果有四个模式字母,则格式使用完整形式。

示例(对于支持此格式的操作系统):

  • v = PT
  • vvvv = 太平洋时间
“其他文本”模式字符串中可以包含文本和标点。但是,从 a 到 z 和从 A 到 Z 的字符都被保留为语法字符,要将其包含在设置了格式的字符串中,则必须使用单引号将其引起来。要将单引号包含在结果字符串中,则必须在模式字符串中使用两个单引号。这两个单引号可以出现在模式字符串中带引号部分的内部或外部。不匹配的单引号对在字符串的结尾处被终止。

示例:

  • 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'

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

参数

pattern:String


引发
TypeError — 如果模式参数为 null。

相关 API 元素

setDateTimeStyles

()方法 
public function setDateTimeStyles(dateStyle:String, timeStyle:String):void

语言版本: ActionScript 3.0
运行时版本: Flash Player 10.1, AIR 2

设置此 DateTimeFormatter 实例的日期和时间样式。日期和时间样式用于将日期和时间格式设置模式设置为操作系统中预定义的、与区域设置相关的模式。此方法可替换使用 DateTimeFormatter() 构造函数或使用 setDateTimePattern() 方法设置的样式。日期和时间模式还根据设置的样式更新。

调用此方法并成功完成后,将 lastOperationStatus 属性设置为:

  • LastOperationStatus.NO_ERROR

否则,将 lastOperationStatus 属性设置为 LastOperationStatus 类中定义的一个常量。

参数

dateStyle:String — 指定设置日期格式时使用的样式。此值对应于由 DateTimeStyle 类枚举的一个值:
  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE
 
timeStyle:String — 指定设置时间格式时使用的样式。此值对应于由 DateTimeStyle 类枚举的一个值:
  • DateTimeStyle.LONG
  • DateTimeStyle.MEDIUM
  • DateTimeStyle.SHORT
  • DateTimeStyle.NONE


引发
ArgumentError — 如果 dateStyletimeStyle 参数不是有效的 DateTimeStyle 常量。
 
TypeError — 如果 dateStyletimeStyle 参数为 null。

相关 API 元素

DateTimeFormatter.1.as

下面的示例说明如何根据区域有区别地设置表示日期和时间值的字符串的格式。此示例中的输出会因操作系统和用户首选项不同而异。

此示例使用下列区域设置:英语(美国)、法语(法国)和西班牙语(西班牙)。

此示例为该列表中的每个区域设置执行下列操作:

  1. 使用默认样式(长日期样式和长时间样式)创建 DateTimeFormatter 对象
  2. 使用默认的长日期样式设置当前日期和时间的格式。
  3. 使用 DateTimeStyle.NONEDateTimeStyle.SHORT 常量更改为仅时间的短日期样式。
  4. 使用仅时间的短日期样式设置当前日期和时间的格式。
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

下面的示例说明应用程序如何根据用户选择的模式设置日期格式。此示例中的输出会因操作系统和用户首选项不同而异。

此示例为该列表中的每个区域设置执行下列操作:

  1. 创建 3 个输入和输出文本字段。
  2. 使用美国英语区域设置创建 DateTimeFormatter 对象。
  3. 调用 configureTextField() 函数,该函数将设置文本字段的位置和大小,并向 patternField 对象添加事件侦听器。
  4. 用户在 patternField 文本字段中输入模式后,textInputHandler 函数将使用该模式设置当前日期和时间的格式,并在输出文本字段中显示结果和 lastOperationStatus 值。
 
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();    
        }
    }
}




[ X ]为什么显示为英语?
《ActionScript 3.0 参考》中的内容以英语显示

《ActionScript 3.0 参考》中的部分内容未翻译成所有语言。当某个语言元素未翻译时,将显示为英语。例如,ga.controls.HelpBox 类未翻译成任何语言。因此在简体中文版的参考中,ga.controls.HelpBox 类显示为英语。