Yes, that's correct. The price will be determined by the currency. In my case, it's kopecks.
// Helper method to get formatted price
public String getFormattedPrice() {
if (price == 0) {
return "Цена не указана";
}
try {
// Преобразуем double в long для работы с целыми числами
long priceValue = (long) price;
// Определяем, на сколько делить по количеству цифр
int length = String.valueOf(priceValue).length();
if (length >= 7) { // 1,000,000 и больше - делим на 1,000,000
priceValue = priceValue / 1000000;
} else if (length >= 5) { // 10,000 и больше - делим на 1,000
priceValue = priceValue / 1000;
} else if (length >= 4) { // 1,000 и больше - делим на 100
priceValue = priceValue / 100;
}
// Форматируем с разделителями тысяч
DecimalFormat formatter = new DecimalFormat("#,###");
return formatter.format(priceValue) + " ₽";
} catch (Exception e) {
// Если произошла ошибка, форматируем оригинальную цену
DecimalFormat formatter = new DecimalFormat("#,###");
return formatter.format((long) price) + " ₽";
}
}