本文整理汇总了C++中TLocale::FormatCurrency方法的典型用法代码示例。如果您正苦于以下问题:C++ TLocale::FormatCurrency方法的具体用法?C++ TLocale::FormatCurrency怎么用?C++ TLocale::FormatCurrency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLocale
的用法示例。
在下文中一共展示了TLocale::FormatCurrency方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleCommandL
// -----------------------------------------------------------------------------
// CLocalizationAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CLocalizationAppUi::HandleCommandL( TInt aCommand )
{
switch( aCommand )
{
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
// Number
case ELocalizationCommandNumber:
{
// buffer for localized text
TBuf<50> myBuf;
// Amount to show
TReal myAmount = 1234.567;
// Real number formatter, initialized with system's current locale settings
TRealFormat myFormat;
// Format real with current locales decimal separator setting
myBuf.AppendNum(myAmount, myFormat);
// Show formatted text
CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
informationNote->ExecuteLD( myBuf );
}
break;
// Currency
case ELocalizationCommandCurrency:
{
// locale is initialized with system's current locale settings
TLocale myLocale;
// buffer for localized text
TBuf<50> myBuf;
// amount is integer, but it is treated as last two digits
// were decimal digits e.g. 1249 = 12.49, 2 = 0.02 ...
TInt myAmount = 123456789;
// Format currency according to current locale settings
myLocale.FormatCurrency(myBuf, myAmount);
// Show formatted text
CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
informationNote->ExecuteLD( myBuf );
}
break;
// Date
case ELocalizationCommandDate:
{
// buffer for localized text
TBuf<50> myBuf;
// Object for datetime data
TTime myDate;
// Set current datetime to object
myDate.HomeTime();
// Format date according to current locale settings
// Format string is universal, so that whatever the locale is,
// date is always formatted correctly
myDate.FormatL(myBuf, _L("%/0%1%/1%2%/2%3%/3%X"));
// Show formatted text
CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
informationNote->ExecuteLD( myBuf );
}
break;
// Time
case ELocalizationCommandTime:
{
// buffer for localized text
TBuf<50> myBuf;
// Object for datetime data
TTime myTime;
// Set current datetime to object
myTime.HomeTime();
// Format time to current locale
// Format string is universal, so that whatever the locale is,
// time is always formatted correctly
myTime.FormatL(myBuf, _L("%-B%:0%J%:1%T%:2%S%:3%+B"));
// Show formatted text
CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
informationNote->ExecuteLD( myBuf );
//.........这里部分代码省略.........