title: Converting the date returned from mongo to this format 2015-10-25
body: <p>I have a json file returned from mongo db as follow:</p>
  
  <pre><code>[
  {
      "_id": {
          "$date": "2014-10-19T04:00:00.000Z"
      },
      "value": 29
  },
  {
      "_id": {
          "$date": "2014-10-20T04:00:00.000Z"
      },
      "value": 20
  },
  {
      "_id": {
          "$date": "2014-10-21T04:00:00.000Z"
      },
      "value": 21
  }
  ]
  </code></pre>
  
  <p>Now I want to read the date in java in the following format: 2014/10/25</p>
  
  <p>but when I use:</p>
  
  <pre><code>System.out.println("DAte is : "+result.get("_id").toString() );
  </code></pre>
  
  <p>the result is : </p>
  
  <pre><code>DAte is : Sun Oct 19 01:00:00 ADT 2014
  </code></pre>
  
  <p>Then only thing that comes to my mind is to use substring and manually convert the date to 2014-10-25 but I am sure there would better way. Does any one have any idea?</p>
  
  <p>Update : </p>
  
  <p>Here is the answer :</p>
  
  <p><a href="https://stackoverflow.com/questions/27805732/converting-date-from-one-format-to-another-does-not-work">converting date from one format to another does not work</a></p>
  
  <p>thanks a lot for helping</p>