[#1697] Date format() java extension should honor current locale

The first commit fixes the issue.
The second and third commit are code cleanups.