Wijmo provides a parsing function library that allows you to use string parsing functions outside of the input widgets, so that you can have matching input and output routines. Wijmo provides two types of parsing functions: Date and Number. Each function has a value parameter, plus other optional parameters. See each type below for further details.
Date parsing takes three parameters. Only the value parameter is required. If the value cannot be parsed with the specified parameters, the function returns null.
Date $.wijinputcore.parseDate(string value, string format, string culture);
Parameter Name | Type | Description |
---|---|---|
value | string | The value to format. |
format | string | The formatting string to use in parsing the date. Default value: d For the full list of supported format keywords, see Date Format Keywords. |
culture | string | The culture to use in parsing the date. |
Date Parsing Examples |
Copy Code |
---|---|
$.wijinputcore.parseDate("9/12/2013"); //returns: new Date(2013,8,12) $.wijinputcore.parseDate("2013/09/12", "yyyy/MM/dd", "ja-JP"); //returns: new Date(2013,8,12) $.wijinputcore.parseDate("午後 11:22:33", "tt hh:mm:ss", "ja-JP"); //returns: new Date(new Date().getFullYear(),0,1,23,22,33) $.wijinputcore.parseDate("00:12:12", "HH:mm:ss", "ja-JP"); //returns: new Date(new Date().getFullYear(),0,1,0,12,12) |
Number parsing takes two parameters. Only the value parameter is required. If the value cannot be parsed with the specified parameters, the function returns null.
Number $.wijinputcore.parseNumber(string value, string culture);
Parameter Name | Type | Description |
---|---|---|
value | string | The value to format. |
culture | string | The culture to use in parsing the number. |
Number Parsing Examples |
Copy Code |
---|---|
$.wijinputcore.parseNumber("12,345.00"); //returns: 12345 $.wijinputcore.parseNumber("12.345,00","de-DE"); //returns: 12345 $.wijinputcore.parseNumber("45.00 %"); //returns: 0.45 $.wijinputcore.parseNumber("$12345.67"); //returns: 12345.67 |