dev Formatstring
Standard Format Strings for Numeric Values
| Format Specifier | Description | Sample Format String | Sample Output |
|---|---|---|---|
| c or C | The number is converted to a string that represents a currency amount. The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default currency precision from the current regional options is used. | c2 | $1,234.00 |
| e or E | The number is converted to a string of the form "-d.ddd...E+ddd" or "-d.ddd...e+ddd", where each 'd' indicates a digit (0-9). The string starts with a minus sign if the number is negative. One digit always precedes the decimal point. The precision specifier indicates the desired number of digits after the decimal point. If the precision specifier is omitted, a default of six digits after the decimal point is used. The case of the format specifier indicates whether to prefix the exponent with an 'E' or an 'e'. The exponent always consists of a plus or minus sign and a minimum of three digits. The exponent is padded with zeros to meet this minimum if required. | E1 | 1.2E+003 |
| n or N | The number is converted to a string of the form "-d,ddd,ddd.ddd...", where each 'd' indicates a digit (0-9). The string starts with a minus sign if the number is negative. Thousand separators are inserted between each group of three digits to the left of the decimal point. The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default currency precision from the current regional options is used. | n0 | 1,234 |
| x or X | The number is converted to a string of hexadecimal digits. The case of the format specifier indicates whether uppercase or lowercase characters are used for hexadecimal digits greater than 9. The precision specifier indicates the minimum number of digits in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier. This format is supported for integral types only. | X8 | 000004D2 |
Standard Format Strings for Date/Time Values
| Format Specifier | Description | Sample Output |
|---|---|---|
| d | Short date pattern. | 3/12/2003 |
| D | Long date pattern. | Wednesday, March 12, 2003 |
| t | Short time pattern. | 12:00 AM |
| T | Long time pattern. | 12:00:00 AM |
| f | Full date/time pattern (short time). | Wednesday, March 12, 2003 12:00 AM |
| F | Full date/time pattern (full time). | Wednesday, March 12, 2003 12:00:00 AM |
| g | General date/time pattern (short time). | 3/12/2003 12:00 AM |
| G | General date/time pattern (full time). | 3/12/2003 12:00:00 AM |
浙公网安备 33010602011771号