NLSPreferencesインタフェース
次に示すように、NLSPrefrencesインタフェースは4つのメソッドを定義します。
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();
}
次のコード・サンプルに、NLSPreferencesインタフェースのサンプル実装を示します。
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;
}
}