title: How can I set date and time formatting in Java that respects the user's OS settings
body: <p>I am running my Java app on a Windows 7 machine where my regional settings are set up to format dates as YYYY-mm-dd and time as HH:mm:ss (e.g. "2011-06-20 07:50:28").  But when I use <code>DateFormat.getDateTimeInstance().format</code> to format my date I do not see that instead I get "20-Jun-2011 7:50:28 AM".  What do I need to do to format dates in the way that my customers have their OS setup to display dates?</p>
  
  <p>Here is what my code in question looks like:</p>
  
  <pre><code>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));
  }
  </code></pre>
  
  <p>The <code>Messages.getFormattedString</code> calls are using <code>MessageFormat</code> to put the date into a sentence that will look like this:</p>
  
  <blockquote>
    <p>Play the turn 'QB Nat vs Ian 008' (received 20-Jun-2011 7:50:28 AM)</p>
  </blockquote>
  
  <p>However my OS settings are setup to format the date as I described above and I expected to see this:</p>
  
  <blockquote>
    <p>Play the turn 'QB Nat vs Ian 008' (received 2011-06-20 07:50:28)</p>
  </blockquote>
  
  <p>I searched here and other Java programming sites and could not find the answer but this seems like such an obvious thing to want to do that I feel like I am missing something obvious.</p>