Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml


Classes:
Keyword

Class TNumberFormat

TComponent
   |
   --TApplicationComponent
      |
      --TControl
         |
         --TI18NControl
            |
            --TNumberFormat

To format numbers in locale sensitive manner use

  1. <com:TNumberFormat Pattern="0.##" value="2.0" />

Numbers can be formatted as currency, percentage, decimal or scientific numbers by specifying the Type attribute. The known types are "currency", "percentage", "decimal" and "scientific".

If someone from US want to see sales figures from a store in Germany (say using the EURO currency), formatted using the german currency, you would need to use the attribute Culture="de_DE" to get the currency right, e.g. 100,00. The decimal and grouping separator is then also from the de_DE locale. This may lead to some confusion because people from US know the "," as thousand separator. Therefore a "Currency" attribute is available, so that the output from the following example results in 100.00.

  1. <com:TNumberFormat Type="currency" Culture="en_US" Currency="EUR" Value="100" />

Namespace: System.I18N

Properties

  • Value, number,
    Gets or sets the number to format. The tag content is used as Value if the Value property is not specified.
  • Type, string,
    Gets or sets the formatting type. The valid types are 'decimal', 'currency', 'percentage' and 'scientific'.
  • Currency, string,
    Gets or sets the currency symbol for the currency format. The default is 'USD' if the Currency property is not specified.
  • Pattern, string,
    Gets or sets the custom number formatting pattern.
  • DefaultText, string,
    Gets or sets the default text. If Value is not set, DefaultText will be
shown instead of the default currency Value/Pattern.

Author: Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
Constants Inherited From TControl
AUTOMATIC_ID_PREFIX, CLIENT_ID_SEPARATOR, CS_CHILD_INITIALIZED, CS_CONSTRUCTED, CS_INITIALIZED, CS_LOADED, CS_PRERENDERED, CS_STATE_LOADED, ID_FORMAT, ID_SEPARATOR, IS_CHILD_CREATED, IS_CREATING_CHILD, IS_DISABLE_THEMING, IS_DISABLE_VIEWSTATE, IS_ID_SET, IS_SKIN_APPLIED, IS_STYLESHEET_APPLIED, RF_ADAPTER, RF_AUTO_BINDINGS, RF_CHILD_STATE, RF_CONTROLS, RF_CONTROLSTATE, RF_DATA_BINDINGS, RF_EVENTS, RF_NAMED_CONTROLS, RF_NAMED_CONTROLS_ID, RF_NAMED_OBJECTS, RF_SKIN_ID,

Method Summary
string
string
getData ()
Get the numberic value for this control.
string
Get the default text value for this control.
protected  string
Formats the localized number, be it currency or decimal, or percentage.
string
Get the number formatting pattern.
string
getType ()
Get the formatting type for this control.
string
Get the numberic value for this control.
void
render ( mixed $writer)
void
setCurrency ( string $currency)
Set the 3-letter ISO 4217 code. For example, the code "USD" represents the US Dollar and "EUR" represents the Euro currency.
void
setData ( string $value)
Set the numberic value for this control.
void
setDefaultText ( string $value)
Set the default text value for this control.
void
setPattern ( string $pattern)
Set the number format pattern.
void
setType ( string $type)
Set the formatting type for this control.
void
setValue ( string $value)
Set the numberic value for this control.
Methods Inherited From TI18NControl
TI18NControl::getCharset(), TI18NControl::getCulture(), TI18NControl::setCharset(), TI18NControl::setCulture()
Methods Inherited From TControl
TControl::addedControl(), TControl::addParsedObject(), TControl::addToPostDataLoader(), TControl::applyStyleSheetSkin(), TControl::autoBindProperty(), TControl::autoDataBindProperties(), TControl::bindProperty(), TControl::broadcastEvent(), TControl::bubbleEvent(), TControl::clearChildState(), TControl::clearControlState(), TControl::clearNamingContainer(), TControl::clearViewState(), TControl::convertUniqueIdToClientId(), TControl::createChildControls(), TControl::createControlCollection(), TControl::dataBind(), TControl::dataBindChildren(), TControl::dataBindProperties(), TControl::ensureChildControls(), TControl::findControl(), TControl::findControlsByID(), TControl::findControlsByType(), TControl::focus(), TControl::getAdapter(), TControl::getAllowChildControls(), TControl::getAttribute(), TControl::getAttributes(), TControl::getChildControlsCreated(), TControl::getClientID(), TControl::getControls(), TControl::getControlStage(), TControl::getControlState(), TControl::getCustomData(), TControl::getEnabled(), TControl::getEnableTheming(), TControl::getEnableViewState(), TControl::getHasAdapter(), TControl::getHasAttributes(), TControl::getHasChildInitialized(), TControl::getHasControls(), TControl::getHasInitialized(), TControl::getHasLoaded(), TControl::getHasLoadedPostData(), TControl::getHasPreRendered(), TControl::getID(), TControl::getNamingContainer(), TControl::getPage(), TControl::getParent(), TControl::getRegisteredObject(), TControl::getSkinID(), TControl::getSourceTemplateControl(), TControl::getTemplateControl(), TControl::getUniqueID(), TControl::getViewState(), TControl::getVisible(), TControl::hasAttribute(), TControl::initRecursive(), TControl::isDescendentOf(), TControl::isObjectRegistered(), TControl::loadRecursive(), TControl::loadState(), TControl::loadStateRecursive(), TControl::onDataBinding(), TControl::onInit(), TControl::onLoad(), TControl::onPreRender(), TControl::onUnload(), TControl::preRenderRecursive(), TControl::raiseBubbleEvent(), TControl::registerObject(), TControl::removeAttribute(), TControl::removedControl(), TControl::render(), TControl::renderChildren(), TControl::renderControl(), TControl::saveState(), TControl::saveStateRecursive(), TControl::setAdapter(), TControl::setAttribute(), TControl::setChildControlsCreated(), TControl::setControlStage(), TControl::setControlState(), TControl::setCustomData(), TControl::setEnabled(), TControl::setEnableTheming(), TControl::setEnableViewState(), TControl::setID(), TControl::setPage(), TControl::setSkinID(), TControl::setTemplateControl(), TControl::setViewState(), TControl::setVisible(), TControl::trackViewState(), TControl::traverseChildControls(), TControl::unbindProperty(), TControl::unloadRecursive(), TControl::unregisterObject(), TControl::__get()
Methods Inherited From TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()
Methods Inherited From TComponent
TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()

Constant Summary

Method Details

getCurrency

public string getCurrency ()

Output
string 3 letter currency code. Defaults to 'USD'.
Exception

getData

public string getData ()

Get the numberic value for this control.

This method is required by IDataRenderer. It is the same as getValue().

Output
string number
Exception

getDefaultText

public string getDefaultText ()

Get the default text value for this control.

Output
string default text value
Exception

getFormattedValue

protected string getFormattedValue ()

Formats the localized number, be it currency or decimal, or percentage.

If the culture is not specified, the default application culture will be used.

Output
string formatted number
Exception

getPattern

public string getPattern ()

Get the number formatting pattern.

Output
string format pattern.
Exception

getType

public string getType ()

Get the formatting type for this control.

Output
string formatting type.
Exception

getValue

public string getValue ()

Get the numberic value for this control.

Output
string number
Exception

render

public void render (mixed $writer )

Input
mixed$writer
Output
Exception

setCurrency

public void setCurrency (string $currency )

Set the 3-letter ISO 4217 code. For example, the code "USD" represents the US Dollar and "EUR" represents the Euro currency.

Input
string$currencycurrency code.
Output
Exception

setData

public void setData (string $value )

Set the numberic value for this control.

This method is required by IDataRenderer. It is the same as setValue().

Input
string$valuethe number value
Output
Exception

setDefaultText

public void setDefaultText (string $value )

Set the default text value for this control.

Input
string$valuedefault text value
Output
Exception

setPattern

public void setPattern (string $pattern )

Set the number format pattern.

Input
string$patternformat pattern.
Output
Exception

setType

public void setType (string $type )

Set the formatting type for this control.

Input
string$typeformatting type, either "decimal", "currency","percentage" or "scientific"
Output
Exception
throwsTPropertyTypeInvalidException

setValue

public void setValue (string $value )

Set the numberic value for this control.

Input
string$valuethe number value
Output
Exception