Appframe Knowledge Base


1 hits
0

How to format dates and numbers using a mask

var vDate = new XDate(2012, 9, 6, true);

/* Calling the af.common.formatByMask, passing a date and a format string,
   will look for the format alias in af.userSession and use that if present. */

af.common.formatByMask(vDate, "Short Date");
// Returns: "06.10.2012" (or whatever the short-date format is for your culture)


/* Calling the af.common.formatByMask function, passing a date and format string
   which is not in af.userSession will just use the provided format string. */

af.common.formatByMask(vDate , "dddd 'the' dS 'of' MMMM yyyy");
// Returns: "Saturday the 6th of October 2012"


/* Calling the af.common.formatByMask, passing a number and a format alias,
   will look for the format alias in af.userSession and use that if present. */

af.common.formatByMask(0.53, "%");
// Returns: "53%"

af.common.formatByMask(1.25e6, "123.12k");
// Returns: "1.25M"

af.common.formatByMask(5123.24, "1 234.1");
// Returns: "5 123,2"

common web · Perma link post comment Posted by: Jan Henrik H. Meling (05-okt-2012)