-
Notifications
You must be signed in to change notification settings - Fork 16
DTSERWFOUR-461-Update decimal places for FX #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fb0f034
95209a9
2fc502a
d975abc
fb0896c
40d2085
fd249b7
2b1d53b
d0954b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,4 +127,27 @@ public CurrencyDetails getCurrency(String currencyCode) { | |
| } | ||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * truncate decimals for given value | ||
| * | ||
| * @param value Any value in string. | ||
| * @param noOfDecimals number of decimal to be truncate. | ||
| * @return Returns truncated decimal value. | ||
| */ | ||
| public static String getValueWithTruncateDecimals(String value, int noOfDecimals) { | ||
| if (value != null) { | ||
| String returnValue = value; | ||
| int decimalLength = 0; | ||
| if (value.contains(".")) { | ||
| decimalLength = value.substring(value.indexOf(".")).length(); | ||
| } | ||
| if (decimalLength > noOfDecimals) { | ||
| returnValue = value.substring(0, value.indexOf(".") + noOfDecimals + 1); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrong implementation, when we are reducing number of decimal places, we can't just truncate the decimals, we either round up or round down values.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Brandon, conformed only truncating the last two decimals not round up the value. |
||
| } | ||
| return returnValue; | ||
| } else { | ||
| return ""; | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.