You need to sign in to do that
Don't have an account?

date format for current locale
We have need to get the date format for the User's locale. I wrote the Apex below. It would return "MM/DD/YYYY" with locale set to US English and "DD/MM/YYYY" for Locale set to UK English. Anyone have a more elegant solutin to get that string? I didn't see any methods in Apex other than to get Locate like EN_US which would require a table lookup or case statement to handle every possible locale.
Date myDate = Date.newInstance(2018,12,31); String myStr = myDate.format(); myStr = myStr.replace('2018','YYYY'); myStr = myStr.replace('12','MM'); myStr = myStr.replace('31','DD'); System.debug(myStr);
http://aljs.appiphony.com/#!/datepickers