Skip to main content

 Hey all — quick question regarding some date parsing deep-dives in an ICU-enabled org (locale testing). I'm noticing this behavior: 

 

start :  

Date d1; 

try { 

    d1 = Date.valueOf('2024-05-21'); // ISO format, always works 

} catch (Exception ex) { 

    System.debug('valueOf failed'); 

 

try { 

    d1 = Date.parse('2024/05/21'); // Fails on en_GB, works on en_ZA 

} catch (Exception ex) { 

    System.debug('parse failed'); 

 

System.debug('Locale: ' + UserInfo.getLocale()); 

 

end: 

 

 It seems Date.parse() is 

locale-sensitive (e.g., en_GB expects dd/MM/yyyy), while Date.valueOf() is locale-agnostic

 as long as the format is ISO.  

 

Q :  For ICU-enabled orgs — what should we watch out for when working with dates and numbers

 (e.g., decimal separators or thousand groupings)? Any gotchas that can break functionality or cause silent failures in dates, formulas, Apex, or integrations?  

 

@* Salesforce Developers * @ICU Locale Formats Adoption @Michael Brown @Vaibhav Mankame

1 answer
0/9000