-
-
Save Vogel612/1ceee5e47234b1c1a53f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String transformFloatingPoint(final String floatingNumber) { | |
int floatingPointIndex = floatingNumber.lastIndexOf('.'); | |
if (floatingPointIndex == -1 || floatingPointIndex < floatingNumber.lastIndexOf(',')) { | |
floatingPointIndex = floatingNumber.lastIndexOf(','); | |
} | |
if (floatingPointIndex == -1) { | |
// no floating point exists | |
return floatingNumber; | |
} | |
final int floatingPointPositionFromEnd = floatingNumber.length() - floatingPointIndex; | |
StringBuilder result = new StringBuilder(floatingNumber.replace(",", "").replace(".", "")); | |
final int newFloatingPointIndex = result.length() - floatingPointPositionFromEnd + 1; | |
result.replace(newFloatingPointIndex, newFloatingPointIndex, "."); | |
return result.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment