3

I want company's locale info in apex code. How can I get that? Basically, I want company's default timezone and default language.

0

3 Answers 3

2

Unfortunately Default Time Zone (and Currency Locale) is not available in Apex. There is an idea for this posted on the idea exchange (http://success.salesforce.com/ideaView?id=08730000000bEGWAA2).

You can get the Language Locale using the method Daniel Blackhall suggested in the other answer.

7

You can query the Organization object to get the information you are looking for.

Organization orgDetails = [SELECT Id, LanguageLocaleKey FROM Organization WHERE Id = :UserInfo.getOrganizationId()];

There are a whole bunch more fields that are available, that I have left out of the answer.

I have included a clause to only return the organization returned by the UserInfo getOrganizationId static method. I don't know if this is required because I assume there will only ever be one organisation record. I can't confirm this, so have added the clause for safety

1
  • How can I get default timezone value?
    – doga
    Commented Oct 30, 2012 at 6:08
2

For anyone still searching for this, here is an updated answer. Building on Daniel Blackhall's answer, you can use the following query to get the Default Time Zone and default Language:

Organization orgDetails = [Select Id, TimeZoneSidKey, LanguageLocaleKey from Organization];

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .