Access keys

DateFormatter

Kind of class: class
Inherits from: BasicClass
Author: Simon Wacker
Classpath: org.as2lib.util.DateFormatter
File last modified: Saturday, 02 July 2005, 22:43:52
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

Constructor

DateFormatter

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

Class properties

APRIL

static APRIL:String = "April"
(read,write)
Fully written out string for april.

AUGUST

static AUGUST:String = "August"
(read,write)
Fully written out string for august.

DAY_AS_NUMBER

static DAY_AS_NUMBER:String = "d"
(read,write)
Placeholder for day in month as number in date format.

DAY_AS_TEXT

static DAY_AS_TEXT:String = "D"
(read,write)
Placeholder for day in week as text in date format.

DECEMBER

static DECEMBER:String = "December"
(read,write)
Fully written out string for december.

DEFAULT_DATE_FORMAT

static DEFAULT_DATE_FORMAT:String = "dd.mm.yyyy HH:nn:ss"
(read,write)
The default date format pattern.

FEBRUARY

static FEBRUARY:String = "February"
(read,write)
Fully written out string for february.

FRIDAY

static FRIDAY:String = "Friday"
(read,write)
Fully written out string for friday.

HOUR_IN_AM_PM

static HOUR_IN_AM_PM:String = "h"
(read,write)
Placeholder for hour in am/pm (1 - 12) in date format.

HOUR_IN_DAY

static HOUR_IN_DAY:String = "H"
(read,write)
Placeholder for hour in day (0 - 23) in date format.

JANUARY

static JANUARY:String = "January"
(read,write)
Fully written out string for january.

JULY

static JULY:String = "July"
(read,write)
Fully written out string for july.

JUNE

static JUNE:String = "June"
(read,write)
Fully written out string for june.

MARCH

static MARCH:String = "March"
(read,write)
Fully written out string for march.

MAY

static MAY:String = "May"
(read,write)
Fully written out string for may.

MILLISECOND

static MILLISECOND:String = "S"
(read,write)
Placeholder for millisecond in date format.

MINUTE

static MINUTE:String = "n"
(read,write)
Placeholder for minute in hour in date format.

MONDAY

static MONDAY:String = "Monday"
(read,write)
Fully written out string for monday.

MONTH_AS_NUMBER

static MONTH_AS_NUMBER:String = "m"
(read,write)
Placeholder for month in year as number in date format.

MONTH_AS_TEXT

static MONTH_AS_TEXT:String = "M"
(read,write)
Placeholder for month in year as text in date format.

NOVEMBER

static NOVEMBER:String = "November"
(read,write)
Fully written out string for november.

OCTOBER

static OCTOBER:String = "October"
(read,write)
Fully written out string for october.

QUOTE

static QUOTE:String = "'"
(read,write)
Quotation beginning and ending token.

SATURDAY

static SATURDAY:String = "Saturday"
(read,write)
Fully written out string for saturday.

SECOND

static SECOND:String = "s"
(read,write)
Placeholder for second in minute in date format.

SEPTEMBER

static SEPTEMBER:String = "September"
(read,write)
Fully written out string for september.

SUNDAY

static SUNDAY:String = "Sunday"
(read,write)
Fully written out string for sunday.

THURSDAY

static THURSDAY:String = "Thursday"
(read,write)
Fully written out string for thursday.

TUESDAY

static TUESDAY:String = "Tuesday"
(read,write)
Fully written out string for tuesday.

WEDNESDAY

static WEDNESDAY:String = "Wednesday"
(read,write)
Fully written out string for wednesday.

YEAR

static YEAR:String = "y"
(read,write)
Placeholder for year in date format.

Instance methods

format

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:
date:
the date-time value to format into a date-time string
Returns:
the formatted date-time string