我刚刚发现 log4j 在我的应用程序中将浮点数打印为指数(例如:2.2388E2)。我希望它将值显示为非指数。(223.88)
该案例发生在客户环境中,我能够模拟。在什么情况下会发生这种事情?知道如何防止这种情况吗?
额外信息:信封文档是使用 CXF 生成的,如果它确实重要的话。
以下是我的单位案例:
@Test
public void testSomething()
{
ServiceEnvelopeDocument serviceEnvelopeDocument = ServiceEnvelopeDocument.Factory.newInstance();
ServiceEnvelope serviceEnvelope = serviceEnvelopeDocument.addNewServiceEnvelope();
ServiceBody serviceBody = serviceEnvelope.addNewServiceBody();
RsDetail rsDetails = serviceBody.addNewRsDetail();
float testFloat = 223.88f;
AuxiliaryAccountStaticBalanceDetail accountStaticBalance = rsDetails.addNewAuxiliaryAccountStaticBalanceDetail();
accountStaticBalance.setAccountBalance(testFloat);
logger.error(""+accountStaticBalance);
logger.error(serviceEnvelopeDocument.toString());
logger.error(String.valueOf(accountStaticBalance));
}`
上面源代码的输出:
2013-01-02 14:55:33.443 ERROR (main) AccountInquiryUtilTest: - <AccountBalance xmlns="http://schemas.ocbc.com/soa/emf/account/elements">223.88</AccountBalance>
2013-01-02 14:55:33.465 ERROR (main) AccountInquiryUtilTest: - <ServiceEnvelope xmlns="http://schemas.ocbc.com/soa/emf/common/envelope/" xmlns:cbs="http://schemas.ocbc.com/soa/emf/service/CBS-CustAccountInfo-I" xmlns:agg="http://schemas.ocbc.com/soa/emf/account/aggregates" xmlns:elem="http://schemas.ocbc.com/soa/emf/account/elements">
<ServiceBody>
<cbs:RsDetail>
<agg:HolderAccountTypeDetail/>
<agg:AuxiliaryAccountStaticBalanceDetail>
<elem:AccountBalance>223.88</elem:AccountBalance>
</agg:AuxiliaryAccountStaticBalanceDetail>
</cbs:RsDetail>
</ServiceBody>
</ServiceEnvelope>
2013-01-02 14:55:33.544 ERROR (main) AccountInquiryUtilTest: - <AccountBalance xmlns="http://schemas.ocbc.com/soa/emf/account/elements">223.88</AccountBalance>
客户环境中的输出:
<ns3:AccountBalance>2.2388E2</ns3:AccountBalance>