title: How to set TTL in Java based app for DynamoDB
body: <p>Hi I need to set time to live programmatically for a table in DynamoDB via AWS Java SDK. Is it possible? I know that TTL feature is introduced recently - <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html" rel="noreferrer">http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html</a></p>
  
  <p><strong>UPDATE:</strong>
  There is no special annotaion, but we can do it manually:</p>
  
  <pre><code>@DynamoDBAttribute
  private long ttl;
  </code></pre>
  
  <p>and configure it as ttl in AWS - <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/time-to-live-ttl-how-to.html" rel="noreferrer">http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/time-to-live-ttl-how-to.html</a></p>
  
  <pre><code>long now = Instant.now().getEpochSecond(); // unix time
  long ttl = 60 * 60 * 24; // 24 hours in sec
  setTtl(ttl + now); // when object will be expired
  </code></pre>