【发布时间】:2018-11-01 04:29:27
【问题描述】:
我可以知道这是什么问题吗?它应该是“5555555556”。请参阅总金额不正确。
我的代码写错了吗? 这是我的代码
//show total amount
try {
SQLiteDatabase db = mSQLiteHelper.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT SUM (Amount) from Donation_Details WHERE strftime('%d %m %Y',CreatedDate) = strftime('%d %m %Y',date('now'))", null);
if (cursor.moveToFirst()) {
int sum = cursor.getInt(0);
DecimalFormat formatter = new DecimalFormat("#,###,###");
String yourFormattedString = formatter.format(sum);
total_Amount.setText("RM " + yourFormattedString);
}
} catch (Exception e) {
e.printStackTrace();
}
如果我写“555555.55”,它不能显示十进制。它只会显示前面的数字。谁能帮帮我?
【问题讨论】:
标签: android formatting calculation