我在Windows 7机器上运行我的Java应用程序,我的区域设置设置为将日期格式设置为YYYY-mm-dd,时间格式为HH:mm:ss(例如"2011-06-20 07:50:28") .但是当我DateFormat.getDateTimeInstance().format用来格式化我的约会时,我没有看到相反,我得到的是"20-Jun-2011 7:50:28 AM".我需要做什么来设置日期,以便客户将其操作系统设置为显示日期?
这是我的代码看起来像:
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));
}
Run Code Online (Sandbox Code Playgroud)
该Messages.getFormattedString呼叫使用MessageFormat把日期成句,这将是这样的:
转牌'QB Nat vs Ian 008'(收到20-Jun-2011 7:50:28 AM)
但是我的操作系统设置被设置为格式化日期,如上所述,我希望看到这个:
转牌'QB Nat vs Ian 008'(收到2011-06-20 07:50:28)
我在这里和其他Java编程站点搜索并找不到答案,但这似乎是一件显而易见的事情,我觉得我错过了一些明显的东西.