I am getting some values in long getJan();
from server and has to format this value so that i have some commas and look nicer. And put that values in List that accept longs, but DecimalFormat is returning String. I must covert to long so that I can put them in my list. I tried both Long.valueOf()
and Long.parseLong()
but values are not shown.
For this post i put only one value but in future it will be more that why I am looping through list.
my code:
List<Entry> lista = new ArrayList<>();
NumberFormat myFormat = NumberFormat.getNumberInstance(Locale.US);
myFormat.setGroupingUsed(true);
DecimalFormat decimalFormat = new DecimalFormat("#.00");
decimalFormat.setGroupingUsed(true);
decimalFormat.setGroupingSize(3);
Long jan = Long.parseLong(decimalFormat.format(netWorthPerMonth.getJan()));
// Log.i(TAG, "setSingleLineChart: " + jan);
List<Long> listOfMonth = new ArrayList<>();
listOfMonth.add(jan);
for (int i = 0; i< handleXAxis().size();i++){
lista.add(new Entry(i, listOfMonth.get(i) ));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.