title: From java.util.concurrent.Future<T> to play.libs.F.Promise<T>: How to do that in Java?
body: <p>I am using play framework to implement a REST API service.</p>
  
  <p>In one function I am using a java async library to talk to another service and it returns a
  <code>java.util.concurrent.Future&lt;T&gt;</code> that I map (using Guava <code>Futures.transform(~)</code>) into a <code>java.util.concurrent.Future&lt;play.mvc.Result&gt;</code>.</p>
  
  <p>Now, how do I make it a <code>play.libs.F.Promise&lt;Result&gt;</code> so that I can make an <code>AsyncResult</code>?</p>
  
  <p>I found <code>play.libs.Akka.asPromise(scala.concurrent.Future&lt;T&gt; future)</code> but I cannot find a way (in Java) to get a scala future from a java one.</p>
  
  <p><strong>EDIT TEMPORARY SOLUTION</strong>:
  Here is what I am using right now:</p>
  
  <pre><code>Future&lt;T&gt; future = asyncGetTheFuture();
  Promise&lt;T&gt; promise = Akka.future(new JFutureToPromise&lt;T&gt;(tempFuture));
  </code></pre>
  
  <p>with</p>
  
  <pre><code>    class JFutureToPromise&lt;T&gt; implements Callable&lt;T&gt; {
          final Future&lt;T&gt; future;
          final long time;
          final TimeUnit unit;
  
          private JFutureToPromise(Future&lt;T&gt; future, long time, TimeUnit unit) {
              this.future = future;
              this.time = time;
              this.unit = unit;
          }
  
          private JFutureToPromise(Future&lt;T&gt; future) {
              this(future, 10L, TimeUnit.SECONDS);
          }
  
          @Override
          public T call() throws Exception {
              return future.get(time, unit);  
          }
      }
  </code></pre>