`
rainwindboy
  • 浏览: 56303 次
  • 性别: Icon_minigender_1
  • 来自: 天津
社区版块
存档分类
最新评论

【积累】Flex中日期的格式化

    博客分类:
  • Flex
阅读更多
在Flex中,有的时候需要对日期做格式化,JAVA中我们已经很熟悉了,Flex中和JAVA大体相同,但是还有一个小小不一样,看下面的例子

 1import mx.formatters.*;
 2private var myDataate=new Date(); 
 3private function changeDatas():void
 4{
 5// 格式化函数
 6var myDateFormatterateFormatter=new DateFormatter();
 7// 定义日期格式
 8myDateFormatter.formatString="YYYY-MM-DD JJ:NN:SS";
 9mx.controls.Alert.show(myDateFormatter.format(myData));
10}

Flex3语言参考手册中,关于DateFormatter的formatString是这样解释的:

The following table describes the valid pattern letters:

 

Pattern letter

 

Description

 

Y

 

 

Year. If the number of pattern letters is two, the year is truncated to two digits; otherwise, it appears as four digits. The year can be zero-padded, as the third example shows in the following set of examples:

 

  • YY = 05
  • YYYY = 2005
  • YYYYY = 02005

M

 

 

Month in year. The format depends on the following criteria:

 

  • 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 short text.
  • If the number of pattern letters is four, the format is interpreted as full text.

Examples:

 

  • M = 7
  • MM= 07
  • MMM=Jul
  • MMMM= July

D

 

 

Day in month. While a single-letter pattern string for day is valid, you typically use a two-letter pattern string.

 

Examples:

 

  • D=4
  • DD=04
  • DD=10

E

 

 

Day in week. The format depends on the following criteria:

 

  • 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 short text.
  • If the number of pattern letters is four, the format is interpreted as full text.

Examples:

 

  • E = 1
  • EE = 01
  • EEE = Mon
  • EEEE = Monday

A

 

 

am/pm indicator.

 

J

 

 

Hour in day (0-23).

 

H

 

 

Hour in day (1-24).

 

K

 

 

Hour in am/pm (0-11).

 

L

 

 

Hour in am/pm (1-12).

 

N

 

 

Minute in hour.

 

Examples:

 

  • N = 3
  • NN = 03

S

 

 

Second in minute.

 

Example:

 

  • SS = 30

Other text

 

 

You can add other text into the pattern string to further format the string. You can use punctuation, numbers, and all lowercase letters. You should avoid uppercase letters because they may be interpreted as pattern letters.

 

Example:

 

  • EEEE, MMM. D, YYYY at L:NN A = Tuesday, Sept. 8, 2005 at 1:26 PM
分享到:
评论

相关推荐

    Flex 代码格式化

    Flex 代码格式化Flex 代码格式化Flex 代码格式化Flex 代码格式化Flex 代码格式化Flex 代码格式化Flex 代码格式化Flex 代码格式化Flex 代码格式化Flex 代码格式化Flex 代码格式化Flex 代码格式化Flex 代码格式化Flex ...

    FlexBuilder代码格式化方法

    标题“FlexBuilder代码格式化方法”涉及到的是在Adobe Flex Builder这款集成开发环境中如何对ActionScript和MXML代码进行美化和格式化的技术。Flex Builder是一款基于Eclipse的IDE,专门用于构建富互联网应用程序...

    flex builder 3 格式化代码

    本文将详细介绍如何在Flex Builder 3中进行代码格式化以及自动添加注释的操作步骤。 首先,为了实现代码格式化的功能,我们需要引入外部的插件。这里提到了两个关键的JAR文件:`ActionscriptInfoCollector_0.7.3....

    Flex自动格式化工具

    在实际应用中,开发者应根据项目需求和团队规范选择合适的Flex自动格式化工具,并确保所有成员都了解并遵循设定的格式规则。这样,不仅可以提高代码的可读性,还能加强团队间的沟通与合作,从而提升整体项目开发效率...

    flex 代码格式化

    标签中的"flex"指的是Flex框架,"格式化"是指代码美化的过程,而"自动对齐"则指代码中的元素如括号、属性等能够自动对齐,使得代码看起来更加整洁有序。自动对齐在编程中是一个重要的辅助功能,它可以帮助开发者快速...

    Flex代码格式化 Flash格式化代码 mxml格式化代码 as格式化代码

    Flex代码格式化、Flash格式化代码、MXML和ActionScript(AS)代码的格式化是针对Adobe Flex开发环境中编写的相关代码进行美化和整理的过程。这一过程对于提高代码可读性、团队协作效率以及遵循编程规范至关重要。...

    Flex格式化代码工具

    在这个场景下,安装Flex格式化代码工具时,需要参照这个文件中的指南,了解如何配置环境、运行工具以及设置自定义格式化规则。 在使用这些工具时,开发者首先需要解压文件,然后根据Readme.txt的指示执行相关的jar...

    flex 代码格式化插件

    总的来说,FlexPrettyPrintCommand插件是Flex开发过程中提高生产力的重要工具,它弥补了Flex Builder 3的不足,让代码格式化变得轻松便捷。对于任何致力于提升开发效率和代码质量的团队而言,这样的插件都是值得尝试...

    Flex代码格式化插件

    Flex代码格式化插件是一种专为Flex开发环境设计的实用工具,主要应用于Eclipse和Flash Builder(FB)等集成开发环境。它可以帮助开发者快速、自动地整理和格式化ActionScript和MXML代码,提高代码的可读性和一致性,...

    Flex 代码格式化工具

    Flex 代码格式化工具 1. 将jar包放在Flex Builder或者Eclipse的plugins文件夹里(例如:C:\Program Files\Adobe\Flex Builder 3\plugins); 2. 重启Flex Builder或Eclipse,必要时使用-clean参数重启; 3. 工具栏...

    FLEX入门篇——日期的格式化

    本文将围绕“FLEX入门篇——日期的格式化”这一主题,深入探讨如何在Flex中处理和格式化日期。日期格式化在任何应用程序中都是常见的需求,尤其是在展示或存储用户友好的时间信息时。 首先,我们要了解Flex中处理...

    flexbuilder3代码格式化插件

    在FlexBuilder3中,虽然内置了一些基本的代码格式化功能,但有时可能无法满足开发者的特定需求。这时,就需要引入第三方插件来增强其代码格式化能力。 "FlexPrettyPrintCommand_0.6.24" 是一个专为FlexBuilder3设计...

    flex 代码格式化包

    Flex代码格式化包是一款专为处理Flex编程语言的代码美化工具。它主要目的是为了提高代码的可读性和一致性,使得开发团队在协作时能够更容易地理解和维护代码。Flex是一种基于ActionScript 3的开放源代码框架,常用于...

    flex组件之格式化组件实例源码

    `DateFormatter`可以根据需要设置日期格式,如“YYYY-MM-DD”或“MM/DD/YYYY”,并且可以轻松地在不同日期格式间切换,满足全球化需求。 第二个实例可能是`NumberFormatter`,它用于格式化数字,支持小数位数的控制...

    FlexBuilder3 格式化插件

    然而,原生的FlexBuilder可能缺乏某些特定的格式化工具,使得代码的格式化工作不够便捷。这时,我们就需要借助第三方插件来提升开发效率。 "FlexPrettyPrintCommand_0.6.31.zip"是一个专门为FlexBuilder3设计的格式...

    Flex 3 代码格式化插件

    `readme.txt`文件则通常包含安装、使用和配置插件的指南,可能包括如何在IDE(如Flash Builder或FlexBuilder)中集成插件、设置格式化规则以及解决常见问题等信息。 在实际应用中,开发者可以自定义格式化规则以...

    flex代码的格式化 eclipse插件

    sf网上下的,在eclipse的flex builder里ctrl+shift+f格式化mxml及as代码

    Flex实现自定义中文日期选择(mx:DateField)

    这篇博客将指导你如何通过自定义来实现Flex中的中文日期选择。 首先,我们需要了解MX:DateField的基本用法。DateField是Flex MX组件库中的一个类,它提供了一个用户界面,用户可以通过该界面选择日期。默认情况下,...

Global site tag (gtag.js) - Google Analytics