title: Exception in thread "main" java.lang.IllegalArgumentException: invalid ObjectId [7887978]
body: <p>I am really facing challenge in changing String object to ObjectId using BSON API. The error I am facing:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: invalid ObjectId [7887978]
      at org.bson.types.ObjectId.&lt;init&gt;(ObjectId.java:130)
      at org.bson.types.ObjectId.&lt;init&gt;(ObjectId.java:124)
      at com.sample.common.Main.main(Main.java:8)
  </code></pre>
  
  <p>The simple code below for reference:</p>
  
  <pre><code>import org.bson.types.ObjectId;
  
  public class Main {
      public static void main(String[] args) {
          String number = "7887978";
          ObjectId id = new ObjectId(number);
          System.out.println(id);
      }
  }
  </code></pre>
  
  <p>How we can solve this error. Any pointers ?</p>
  
  <p>Edit: Maven dependency that I used:</p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;org.mongodb&lt;/groupId&gt;
              &lt;artifactId&gt;bson&lt;/artifactId&gt;
              &lt;version&gt;2.3&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>