Created
December 13, 2018 08:06
-
-
Save galihlprakoso/97a309cf40f1142dd73bc8b5d7d5e82a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package galihlprakoso.com.solid; | |
import java.text.NumberFormat; | |
import java.util.ArrayList; | |
import java.util.Locale; | |
/** | |
* | |
* @author galihlarasprakoso | |
*/ | |
class GODClass { | |
private ArrayList<Integer> getListDataHarga(){ | |
ArrayList<Integer> listDataHarga = new ArrayList<>(); | |
listDataHarga.add(5000); | |
listDataHarga.add(6000); | |
listDataHarga.add(7000); | |
listDataHarga.add(8000); | |
listDataHarga.add(9000); | |
listDataHarga.add(10000); | |
return listDataHarga; | |
} | |
public ArrayList<String> ambilListHarga(){ | |
ArrayList<Integer> listDataHarga = getListDataHarga(); | |
ArrayList<String> listDataHargaFormatted = new ArrayList<>(); | |
for (int i = 0; i < listDataHarga.size(); i++) { | |
String hargaFormatted = formatMataUang(listDataHarga.get(i)); | |
listDataHargaFormatted.add(hargaFormatted); | |
} | |
return listDataHargaFormatted; | |
} | |
public String formatMataUang(Integer angka){ | |
Locale localeID = new Locale("in", "ID"); | |
NumberFormat format = NumberFormat.getCurrencyInstance(localeID); | |
return format.format(angka); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment