Locale FormatString Examples

These examples show you the strength of the locale.formatstring() viper. Specify any kind and/or number of input parameters (datetime, number, string) and a format string, and see how easy it is to format e.g. datetimes and numbers within a specific culture.

The locale.formatstring() viper uses the .NET String.Format() method, which uses the composite formatting feature, so anything you can do with this method you can do with this viper as well.

Some standard numeric format specifiers:

  • C - Currency
  • D - Decimal
  • E - Scientific
  • P - Percent
  • X - Hexadecimal

Some standard datetime format specifiers:

  • d - Short date
  • D - Long date
  • t - Short time
  • T - Long time
  • f - Full date/short time
  • F - Full date/long time 
Smartsite SXML CopyCode image Copy Code
{buffer.set(d, datetime.getdate(2009,11,13,14,30,0))}
{locale.setlocale("nl-NL")}

{locale.formatstring("{0:d}", $d)} <br/>
{locale.formatstring("{0:D}", $d)} <br/>
{locale.formatstring("{0:F}", $d)} <br/>

{locale.formatstring("{0:C}", 1000)} <br/>
{locale.formatstring("{0:D}", 1000)} <br/>
{locale.formatstring("{0:E}", 1000)} <br/>
{locale.formatstring("{0:X}", 1000)} <br/>
Example Result CopyCode image Copy Code
13-11-2009 <br/>
vrijdag 13 november 2009 <br/>
vrijdag 13 november 2009 14:30:00 <br/>
&#8364; 1.000,00 <br/>
1000 <br/>
1,000000E+003 <br/>
3E8 <br/>