how to insert long date type in mongodb through java.

843 views
Skip to first unread message

Navneet Mathpal

unread,
Mar 14, 2014, 2:36:42 AM3/14/14
to mongod...@googlegroups.com
hi,

mongodb use long as NumberLong("123123"),and stores in Int64.
how to insert long value in mongodb through java application. if I am sending datatype as long it is explicitly converting into the double.

Asya Kamsky

unread,
Mar 14, 2014, 8:25:16 AM3/14/14
to mongodb-user
I just tried a quick test and when I store a long datatype then it's
stored as NumberLong()

Code:
long l=1;
collection.insert(new BasicDBObject().append("number", l));

Result:
{ "_id" : ObjectId("5322f4ad300483566f0445c3"), "number" : NumberLong(1) }

Can you show the code you are using so we can see what's different?

Asya
> --
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb
>
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Navneet Mathpal

unread,
Mar 14, 2014, 3:28:30 PM3/14/14
to mongod...@googlegroups.com
Asya 
Thanks for replying .. got its solution .



You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/tYfKM5N3XjU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages