我做了以下事情
MathContext context = new MathContext(7, RoundingMode.HALF_UP);
BigDecimal roundedValue = new BigDecimal(value, context);
// Limit decimal places
try {
roundedValue = roundedValue.setScale(decimalPlaces, RoundingMode.HALF_UP);
} catch (NegativeArraySizeException e) {
throw new IllegalArgumentException("Invalid count of decimal places.");
}
roundedValue = roundedValue.stripTrailingZeros();
String returnValue = roundedValue.toPlainString();
Run Code Online (Sandbox Code Playgroud)
如果输入现在为"-0.000987654321"(=值),我返回"-0.001"(=返回值)即可.
如果输入现在为"-0.0000987654321",我会返回"-0.0001",这也没关系.
但是当输入现在是"-0.00000987654321"时,我得到"0.0000"而不是"0",这是不行的.这有什么不对?为什么在这种情况下不删除尾随零?
我的jar文件的签名中包含以下条目
Timestamped by "CN=GlobalSign TSA for Advanced - G3 - 001-02, O=GMO GlobalSign K.K., C=JP" on Mo Apr 10 11:48:34 UTC 2017
Timestamp digest algorithm: SHA-256
Timestamp signature algorithm: SHA256withRSA, 2048-bit key
Run Code Online (Sandbox Code Playgroud)
我已经发现在Java版本低于1.7.0_76的系统上运行jar文件时,时间戳摘要算法的SHA-256和时间戳签名算法的SHA256withRSA会引起问题。
有人可以告诉我时间戳摘要和时间戳签名支持这两种算法的哪个Java版本吗?