是否可以強制GWT應用程序在其他語言環境中使用特定區域設置格式?如何在GWT應用程序中顯示一種格式?
我試過以下兩種方法。
// 1
private final static DateTimeFormat timeFormat1 = DateTimeFormat.getFormat("h:mm aa");
// 2
private final static DateTimeFormat timeFormat2 = DateTimeFormat.getFormat(PredefinedFormat.TIME_SHORT);
public static void convertToShortTimeFormat(Date d) {
if (d != null) {
GWT.log(timeFormat1.format(d)); // displays localized format "10:30 vorm" in German
GWT.log(timeFormat2.format(d)); // displays "19:30" for example
}
}
例如,在北美,我們用時間格式化像12:34,但其他國家AM/PM可能成爲其國家的語言。有什麼方法可以始終顯示12小時的符號嗎?
您自己設置語言環境。那麼你的問題到底是什麼? –
我的意思是我總是希望時間格式相同,在這種情況下北美風格12:34 AM(PM)無論選擇哪種語言環境。 例如在德語中,英語中的「12:34 AM」在我的GWT應用程序中變得像「12:34 vorm」,但我希望顯示AM/PM模式的格式。 –