这是我的代码如下:
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将日期放入一个如下所示的句子:
Play the turn ‘QB Nat vs Ian 008’ (received 20-Jun-2011 7:50:28 AM)
但是,我的操作系统设置是按照上述格式设置日期,我预计会看到:
Play the turn ‘QB Nat vs Ian 008’ (received 2011-06-20 07:50:28)
我在这里搜索和其他Java编程网站,找不到答案,但这似乎是一件很明显的事情,想要做,我觉得我缺少一些明显的东西.
解决方法
The user might choose to override some of the values associated with the current culture of Windows through the regional and language options portion of Control Panel. For example,the user might choose to display the date in a different format or to use a currency other than the default for the culture. If the CultureInfo.UseUserOverride property is set to true,the properties of the CultureInfo.DateTimeFormat object,the CultureInfo.NumberFormat object,and the CultureInfo.TextInfo object are also retrieved from the user settings.
如果您需要此功能,我建议您以系统依赖于Windows的方式执行此操作(例如,以@laz建议的方式访问Windows注册表).