Class fever.data.formatter.DateFormatter

Implemented Interfaces

LocalisationListener

Description

DateFormatter class uses a pattern formated String to render date and time from a Date object.

If no pattern is defined, use pattern "DD/MM/YYYY" by default.

Pattern can be defined with many terms, pre-defined are :

You can add or override pattern parsing method using addType method.

Example

   var f : DateFormatter = new DateFormatter();
   f.formatString = "EE DD MMMM YYYY - HH:NN:SS";
   var s : String = f.format( new Date() );
 

Field Index

formatString

Inherited from Formatter

Method Index

new DateFormatter()
addType(), connectToLocalisation(), format(), onLocalisationUpdate(), removeType()

Inherited from Formatter

Constructor Detail

DateFormatter

public function DateFormatter()

Constructor.

Field Detail

formatString

public formatString:String
Formating pattern.

Usually, formatting pattern is auto defined using Localisation loaded.
If you set the pattern using this setter, formatter no longer listen to localisation change.

Call connectToLocalisation() method to reconnect formatter to localisation API.

Method Detail

addType

public function addType(type:String, scope, f:Function):Void

Defines custom formatting method for specific token.

Parameters

typeToken to search for
scopeContext of f method
fFormatting method

removeType

public function removeType(type:String):Void

Removes type to formatter

format

public function format(value:Date):String

Formats and returns passed-in value.

Return

Formatted String

Overrides

format() in fever.data.formatter.Formatter

onLocalisationUpdate

public function onLocalisationUpdate(event:LocalisationEvent):Void

Triggered when Localisation language change.

Specified By

onLocalisationUpdate() in fever.app.local.LocalisationListener

connectToLocalisation

public function connectToLocalisation():Void

Adds current formatter as Localisation listener.
Thus formatting pattern is autoupdate with current used lang.