10.4.6 Formatters
10.4.6.1 numeric
Description
format from a Number to a String and parse to a Number
Specifications
numeric
-
rawFormat : Set to true if no locale formatting is needed. Default is false.
- format (Number) returns String
- parse (string) returns Number: parses a string and returns the converted Number
10.4.6.2 numeric-range
Description
Formats a String of format
"Number1 - Number2"
to object:
{ start: Number, end : number }
and vice versa.
Specifications
numeric-range
-
rawFormat : Set to true if no locale formatting is needed. Default is false.
- format (object) returns String : formats a integer range object {start: Number, end: Number} to a String "Number1 - Number2"
- parse (string) returns object : parses a String "Number1 - Number2" to an integer range object {start: Number, end: Number}
10.4.6.3 pattern
Description
use a pattern to format or parse
patterns:
- $ : alfanumeric
- # : digit
- * : whatever character
Specifications
pattern
-
pattern : pattern to use, default is "*"
- format (String) returns string : formats a String using the specified pattern
- parse (string) returns String : parses a string using the specified pattern and the converted String
Example
Pattern for a Belgian bank account: ###-#######-##
var f = getFormatter("pattern", {
pattern :"###-#######-##"
});
format of "737000003679" returns "737-0000036-79",
parse of " 737-0000036-79 " returns "737000003679" (remark the trimmed
string).
10.4.6.4 pattern-date
Specifications
pattern-date
- pattern (string) : format in which dates will be formatted and format that will be expected when parsing dates. The default pattern is the ISO-8601 format (yy-mm-dd). Example 2008-05-16. The syntax used for specifying the date format is the one used by the jQuery datepicker.
- format (Date) returns spring : formats a Date using the specified pattern
- parse (string) returns Date : parses a string using the specified pattern and returns a Date
10.4.6.5 pattern-date-range
TODO
10.4.6.6 short-date
Description
short-date is a pattern-date with a preconfigured pattern. Formatter is based on jQuery formatDate patterns.
Specifications
short-date
-
pattern : default value is dd/mm/yy (jQuery formatDate pattern). Example 16/05/2008
- format (String) returns string : formats a Date using the specified pattern and returns the String
- parse (string) returns Date: parses a string using the specified pattern and return the Date
10.4.6.7 short-date-range
TODO
10.4.6.8 time
Description
time is structure of format "hh:mm:ss"
Specifications
time
- format (Date) returns String : formats a Date using the specified pattern and returns the String
- parse (String) returns Date: parses a string using the specified pattern and return the Date
10.4.6.9 true-false
Description
formatter to formats or parses a Boolean value
Specifications
true-false
- format (Boolean) returns String : return "true" or "false"
- parse (String) returns Boolean: returns false in case of "false" (case insensitive) or true in all other cases
10.4.6.10 wire-date
Description
wire-date is a pattern-date with a preconfigured pattern.
Specifications
wire-date
-
pattern : the ISO8601 format dd/mm/yy. (jQuery formatDate pattern). Example 16/05/2008
- format (Date) returns String : formats a Date using the specified pattern and returns the String
- parse (String) returns Date: parses a string using the specified pattern and return the Date
10.4.6.11 wire-date-range
Description
wire-date-range parses date separated by a specified separator to object {start: Date, end : Date}
Specifications
wire-date-range
-
rangeSeparator : default value is "/"
- format (Object) returns String : formats Object {start: Date, end : Date} to String "startDate / endDate"
- parse (String) returns Object: parses a String "startDate / endDate" to Object {start: Date, end : Date}
10.4.6.12 wire-date-time
Description
wire-date-time parses date and time separated by a specified separator to objects {date: datePart, time : timePart} where datePart and timePart are just 2 Strings
Specifications
wire-date-time
-
timeSeparator : default is "T"
- pattern : default is the ISO_8601 format
- format (Object) returns String : formats Object {date: String, time : String} to String "dateStringTtimeString"
- parse (String) returns Object: parses a String "dateStringTtimeString" to Object {date: String, time : String}
Previous