title: How to validate Unix Timestamp in Java?
body: <p>I have an Android application that stores a unix timestamp of a certain event in shared preferences. Since those files can be accessed (and modified) by anyone who has a rooted phone, I'm applying a validation check in my app before processing that value. So, my question is, how can a unix timestamp be validated? </p>
  
  <p>For example</p>
  
  <pre><code>String timestamp = "1415251687";
  validateUnixTime(timestamp);
  </code></pre>
  
  <p>should return <code>true</code> and</p>
  
  <pre><code>timestamp = "1415-dummydata";
  validateUnixTime(timestamp);
  </code></pre>
  
  <p>should return <code>false</code></p>
  
  <p><strong>Edit:</strong> Just to be clear, I'm storing (and fetching) the value of timestamp as <code>long</code> from shared preferences. The code above was just for the sake of simplicity. The function should accept a <code>long</code> as its parameter, validate it, and return <code>true</code> or <code>false</code> based on it being a valid unix timestamp value.</p>