The NLSPreferences Interface
The NLSPrefrences
interface defines four methods as shown below:
public interface NLSPreferences { /** * Returns the locale to be used. **/ Locale getLocale(); /** * Return the timezone to be used. **/ TimeZone getTimeZone(); /** * Return the dateformat to be used. */ String getDateFormat(); /** * Return the time format to be used. */ String getTimeFormat(); /** * Returns the grouping seperator. */ char getGroupingSeparator(); /** * Returns the grouping seperator. */ char getDecimalSeparator(); }
The code sample below shows a sample implementation of the NLSPreferences
interface:
public class MyNLSPreferences implements NLSPreferences { private static final String DATE_STYLE = "yyyy-MM-dd"; private static final String TIME_STYLE = "HH-mm-ss"; private static final char G_SEP = ','; private static final char D_SEP = '.'; public Locale getLocale() { return Locale.FRENCH; } public TimeZone getTimeZone() { return TimeZone.getTimeZone("America/Los_Angeles"); } public String getDateFormat() { return DATE_STYLE; } public String getTimeFormat() { return TIME_STYLE; } public char getGroupingSeparator() { return G_SEP; } public char getDecimalSeparator() { return D_SEP; } }