我在Windows 7机器上运行Java应用程序,在该机器上,我的区域设置已设置为将日期格式设置为YYYY-mm-
dd,将时间格式设置为HH:mm:ss(例如“ 2011-06-20 07:50:28”)
。但是,当我使用DateFormat.getDateTimeInstance().format格式设置日期时,却看不到“
2011年6月20日上午7:50:28”。我需要做些什么来格式化客户自己的操作系统来显示日期的日期格式?
这是我所讨论的代码如下所示:
File selGameLastTurnFile = selectedGame.getLastTurn ().getTurnFile ();
Date selGameModifiedDate = new Date (selGameLastTurnFile.lastModified());
if (selectedGame.isYourTurn ()) {
gameInfo = Messages.getFormattedString ("WhoseTurnIsIt.Prompt.PlayTurn", //$NON-NLS-1$
FileHelper.getFileName (selGameLastTurnFile),
DateFormat.getDateTimeInstance().format(selGameModifiedDate));
} else {
gameInfo = Messages.getFormattedString ("WhoseTurnIsIt.Prompt.SentTurn", //$NON-NLS-1$
selGameLastTurnFile.getName (),
DateFormat.getDateTimeInstance().format(selGameModifiedDate));
}
该Messages.getFormattedString呼叫使用MessageFormat把日期成句,这将是这样的:
转牌为“ QB Nat vs Ian 008”(2011年6月20日上午7:50:28接收)
但是,我的操作系统设置被设置为如上所述格式化日期,并且我希望看到以下内容:
转牌’QB Nat vs Ian 008’(2011-06-20 07:50:28接收)
我在这里和其他Java编程站点中进行了搜索,但找不到答案,但这似乎是一件很明显的事情,我想我似乎缺少了一些明显的东西。