Localization, multi-currency and time zones in code
How custom labels, toLabel(), CurrencyIsoCode, convertCurrency(), dated exchange rates and the Date, Datetime and LWC i18n APIs decide which language, currency, time zone and format your code returns to each user.
Demonstrate knowledge of localization and multi-currency features and capabilities and how they affect coding.
~8 min read · 15 practice questions ·
What the exam expects
- Reference a translated custom label from Apex, Lightning web components and Aura, and resolve a label in a language other than the running user's.
- Return translated picklist values from SOQL with
toLabel()and locale-formatted values withFORMAT(). - Predict the currency of a queried amount: the record's own currency, the user's currency through
convertCurrency(), or the org's default currency for grouped aggregates. - Know where dated exchange rates apply under advanced currency management and what to do in code where they don't.
- Pick the Date and Datetime method that applies the user's time zone and locale, or GMT, and format numbers and currency in LWC from the user's Salesforce locale.
Key terms: custom label (translatable text value referenced from code), CurrencyIsoCode (the field that sets the currency of every amount on a record), corporate currency (the headquarters currency that conversion rates are relative to), advanced currency management (dated exchange rates mapped to date ranges), context user (the user whose time zone, locale and language the methods apply).
Key facts
- Detail
- Up to 5,000 per org (managed-package labels excluded), 1,000 characters each
Label.get('', name, lang)- Detail
- Empty namespace means the org namespace; overrides the user's language
- Detail
- Amounts keep their number and show the new code
convertCurrency() in WHERE- Detail
- Error; use an ISO-code literal such as
USD5000
- Detail
- Returned in the org's default currency
- Detail
- Opportunity-family objects and their reports only; not Currency formulas
UserInfo.getDefaultCurrency()- Detail
- User's currency in multi-currency orgs, org currency otherwise
Datetime.valueOfGmt(str)- Detail
- Expects
yyyy-MM-dd HH:mm:ssin GMT
Date.toStartOfWeek()- Detail
- Depends on the user's locale: Sunday (US), Monday (Europe)
Sources for this section (8)
- Custom Labelshelp.salesforce.com (opens in a new tab)
- Label Classdeveloper.salesforce.com (opens in a new tab)
- Manage Multiple Currencieshelp.salesforce.com (opens in a new tab)
- convertCurrency()developer.salesforce.com (opens in a new tab)
- About Advanced Currency Managementhelp.salesforce.com (opens in a new tab)
- UserInfo Classdeveloper.salesforce.com (opens in a new tab)
- Datetime Classdeveloper.salesforce.com (opens in a new tab)
- Date Classdeveloper.salesforce.com (opens in a new tab)
- Why does `System.Label.Shipment_Delayed` return English in a scheduled job that emails French contacts?
- When do you query `DatedConversionRate` yourself instead of relying on `convertCurrency()`?
- Why can't a Visualforce page show Opportunity `Amount` with `<apex:outputField>` under advanced currency management?
- What does `WHERE Amount > 50000` without an ISO code compare?
The questions are free to read. Answers with their sources and self-grading are included with the pack.
Keep reading with the Platform Developer II pack
- Core concepts
- Exam traps
- Worked scenario
The pack includes:
- All 28 lessons of the Platform Developer II guide, with reading progress
- Interactive decision walks and step-by-step sequence steppers
- Inline practice questions and one-click topic practice (15 questions for this lesson)
- An official source cited for every claim
- An AI tutor that answers from the guide
- Unlimited timed practice exams