Salesforce Certified Platform Developer II — Question 36
Which method should be used to convert a Date to a String in the current user's locale?
Answer options
- A. Date.format
- B. String.format
- C. String.valueOf
- D. Date.parse
Correct answer: A
Explanation
The correct answer is A, as Date.format is specifically designed for formatting Date objects to Strings while considering the user's locale. The other options either serve different purposes, like String.format for formatting Strings or String.valueOf for converting objects to Strings without locale considerations.