I have a json file returned from mongo db as follow:
[
{
"_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
}
]
Now I want to read the date in java in the following format: 2014/10/25
but when I use:
System.out.println("DAte is : "+result.get("_id").toString() );
the result is :
DAte is : Sun Oct 19 01:00:00 ADT 2014
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?
Update :
Here is the answer :
converting date from one format to another does not work
thanks a lot for helping