Localizing dates and times

Localize Date & Time

Here's an example of creating a DateFormat object to format a date according to local conventions, both language and time zone:

DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT, (new ResourceLoader()).getLocale() );
df.setTimeZone(TimeService.getLocalTimeZone());

Here's an example of creating a DateFormat object to format a date according to local conventions, and extracting the pattern string for later use:

DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT, (new ResourceLoader()).getLocale() );
df.setTimeZone(TimeService.getLocalTimeZone());
date_entry_format_description = ((SimpleDateFormat)df).toPattern();