+ Start a Discussion
SFDC_DeveloperSFDC_Developer 

How to know date format of Users

How to know the date format of the user in salesforce. Basically I want to perform some operation based on user's date format.
Like:
If(date_format == dd/mm/yyyy) 
{ do this } 
if(date_format == mm/dd//yyyy) 
​{ do this }


I know we can use Map to store the locale as key and date format as values and then query the locale and get the date format, but it is very lengthy and it will also increase the no. of lines in code.
Anup JadhavAnup Jadhav
Perhaps a more useful implementation would be to check the user's locale (us, uk) instead of dates, which i am pretty sure is translated into a common format in apex. 

You can see more details on the user locale here - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_userinfo.htm#apex_System_UserInfo_getLocale