java - Simplest way to retrieve an int from a mongo result? -
i'm pulling int mongo cursor object so:
dbobject mapobj = cursor.next(); int autostart = (int) (double) (double) mapobj.get("autostart");
it seems strange have triple cast integer, there better way?
i think looking this:
dbobject mapobj = cursor.next(); int autostart = ((number) mapobj.get("autostart")).intvalue();
no conversion string , safe if value gets converted double or long (with potential loss of precision) original integer value. double, long , integer extend number.
hth rob
Comments
Post a Comment