Q: Can't parse String to Long and use it in list 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) ));
        }


A: A long or an int can not have any decimal values. For decimal values you have to use either float or double. But if you want to format the value and display in a list you should probably go with a string.
