I am trying to put a long value(milliseconds) in JSONArray like this :
long epoc = 1359231233L;
long milli = epoc*1000;
System.out.println(milli);
JSONArray arr = new JSONArray();
arr.put((Long)epoc*1000);
System.out.println(arr.toString());
The output is :
1359231233000
[1.359231233e12]
I don’t want the exponent value in array , how can i get it to display the actual long value ?
The form you’re seeing isn’t in the array. It’s being created by
toString. The value actually in the array is aLong, not a string.If you want to get the string form of that number without using exponent notation, I expect you’ll have to write your own long-to-string routine (or find one, perhaps in Apache commons or similar).
Note that the exponent form is perfectly acceptable JSON.