title: In JSF - Getting the Client's Locale (To Display time in browser's timezone)
body: <p>I'm writing a webapp in JSF 2.0 that displays Timestamps as part of the information to the user.
  I would like the user to see the timestamps localized to their location (browser's locale).</p>
  
  <p>So far, whatever I did, the timestamps would always appear localized to the timezone of the server.</p>
  
  <p>I tried getting the locale with these methods:</p>
  
  <pre><code>Locale browserLocale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Locale browserLocale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
  </code></pre>
  
  <p>Both returned the server's locale.</p>
  
  <p>I then use the locale object with <code>SimpleDateFormat</code> to print timestamps.</p>
  
  <p>Am I using the correct API?<br>
  I've read somewhere that you have to use client side code (Javascript) to get the browser's timezone. Is that correct? How would you do that?</p>
  
  <p>Thank's 'n' Advance.</p>
  
  <p><strong>UPDATE</strong> found <a href="http://www.pageloom.com/automatic-timezone-detection-with-javascript" rel="noreferrer">this</a> (jsTimezoneDetect) JavaScript code. But I'm still not sure how to translate the timezone to a Java <code>Locale</code> Object</p>