我对某些销售数据有以下格式的具体细节。
销售文件中将通过以下代码的数量有一个小数点,后面有两个数字。我想删除小数点和之后的数字,例如1.00变为1。
@Override
public void setFormatSpecificDetails(Sales salesRecord) {
salesRecord.setHostStoreNumber("1");
salesRecord.setRetailValue(salesRecord.getNetRetailValue());
salesRecord.setDiscountValue(0);
salesRecord.setTransactionType("SR");
salesRecord.setQuantity(salesRecord.getQuantity());
答案 0 :(得分:0)
Just Typecast the value to int or long. its very simple
long l =(long) salesRecord.getNetRetailValue();
System.out.println(l);
the code yours will be like this
@Override
public void setFormatSpecificDetails(Sales salesRecord) {
salesRecord.setHostStoreNumber("1");
salesRecord.setRetailValue(salesRecord.getNetRetailValue());
salesRecord.setDiscountValue(0);
salesRecord.setTransactionType("SR");
salesRecord.setQuantity((long)salesRecord.getQuantity());
答案 1 :(得分:-1)
您可以使用java.math.BigDecimal:
new BigDecimal("1.00").setScale(0)