Class org.as2lib.util.DateFormatter

org.as2lib.core.BasicClass
   +--org.as2lib.util.DateFormatter

Description

DateFormatter formats a given date with a specified pattern.

Use the declared constants as placeholders for specific parts of the date-time.

All characters from 'A' to 'Z' and from 'a' to 'z' are reserved, although not all of these characters are interpreted right now. If you want to include plain text in the pattern put it into quotes (') to avoid interpretation. If you want a quote in the formatted date-time, put two quotes directly after one another. For example: "hh 'o''clock'".

Example: var formatter:DateFormatter = new DateFormatter("dd.mm.yyyy HH:nn:ss S"); trace(formatter.format(new Date(2005, 2, 29, 18, 14, 3, 58)));

Output:

   29.03.2005 18:14:03 58
 

Field Index

APRIL, AUGUST, DAY_AS_NUMBER, DAY_AS_TEXT, DECEMBER, DEFAULT_DATE_FORMAT, FEBRUARY, FRIDAY, HOUR_IN_AM_PM, HOUR_IN_DAY, JANUARY, JULY, JUNE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH_AS_NUMBER, MONTH_AS_TEXT, NOVEMBER, OCTOBER, QUOTE, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TUESDAY, WEDNESDAY, YEAR

Method Index

new DateFormatter()

format()

Inherited from BasicClass

toString()

Constructor Detail

DateFormatter

public function DateFormatter(dateFormat:String)

Constructs a new DateFormatter instance.

If you do not pass-in a dateFormat or if the passed-in one is null or undefined the DEFAULT_DATE_FORMAT is used.

Parameters

dateFormat(optional) the pattern describing the date and time format

Field Detail

DEFAULT_DATE_FORMAT

static public DEFAULT_DATE_FORMAT:String
The default date format pattern.

YEAR

static public YEAR:String
Placeholder for year in date format.

MONTH_AS_NUMBER

static public MONTH_AS_NUMBER:String
Placeholder for month in year as number in date format.

MONTH_AS_TEXT

static public MONTH_AS_TEXT:String
Placeholder for month in year as text in date format.

DAY_AS_NUMBER

static public DAY_AS_NUMBER:String
Placeholder for day in month as number in date format.

DAY_AS_TEXT

static public DAY_AS_TEXT:String
Placeholder for day in week as text in date format.

HOUR_IN_AM_PM

static public HOUR_IN_AM_PM:String
Placeholder for hour in am/pm (1 - 12) in date format.

HOUR_IN_DAY

static public HOUR_IN_DAY:String
Placeholder for hour in day (0 - 23) in date format.

MINUTE

static public MINUTE:String
Placeholder for minute in hour in date format.

SECOND

static public SECOND:String
Placeholder for second in minute in date format.

MILLISECOND

static public MILLISECOND:String
Placeholder for millisecond in date format.

QUOTE

static public QUOTE:String
Quotation beginning and ending token.

JANUARY

static public JANUARY:String
Fully written out string for january.

FEBRUARY

static public FEBRUARY:String
Fully written out string for february.

MARCH

static public MARCH:String
Fully written out string for march.

APRIL

static public APRIL:String
Fully written out string for april.

MAY

static public MAY:String
Fully written out string for may.

JUNE

static public JUNE:String
Fully written out string for june.

JULY

static public JULY:String
Fully written out string for july.

AUGUST

static public AUGUST:String
Fully written out string for august.

SEPTEMBER

static public SEPTEMBER:String
Fully written out string for september.

OCTOBER

static public OCTOBER:String
Fully written out string for october.

NOVEMBER

static public NOVEMBER:String
Fully written out string for november.

DECEMBER

static public DECEMBER:String
Fully written out string for december.

MONDAY

static public MONDAY:String
Fully written out string for monday.

TUESDAY

static public TUESDAY:String
Fully written out string for tuesday.

WEDNESDAY

static public WEDNESDAY:String
Fully written out string for wednesday.

THURSDAY

static public THURSDAY:String
Fully written out string for thursday.

FRIDAY

static public FRIDAY:String
Fully written out string for friday.

SATURDAY

static public SATURDAY:String
Fully written out string for saturday.

SUNDAY

static public SUNDAY:String
Fully written out string for sunday.

Method Detail

format

public function format(date:Date):String

Formats the passed-in date with the specified date format pattern into a date-time string and returns the resulting string.

If the passed-in date is null or undefined, the current date-time will be used instead.

Parameters

datethe date-time value to format into a date-time string

Return

the formatted date-time string