fix parsing of bytes value
This commit is contained in:
parent
feb854b742
commit
f79719beaa
|
@ -129,9 +129,7 @@ public class ByteSizeValue implements Serializable, Streamable {
|
|||
}
|
||||
long bytes;
|
||||
try {
|
||||
if (sValue.endsWith("b")) {
|
||||
bytes = Long.parseLong(sValue.substring(0, sValue.length() - 1));
|
||||
} else if (sValue.endsWith("k") || sValue.endsWith("K")) {
|
||||
if (sValue.endsWith("k") || sValue.endsWith("K")) {
|
||||
bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * ByteSizeUnit.C1);
|
||||
} else if (sValue.endsWith("kb")) {
|
||||
bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 2)) * ByteSizeUnit.C1);
|
||||
|
@ -143,6 +141,8 @@ public class ByteSizeValue implements Serializable, Streamable {
|
|||
bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * ByteSizeUnit.C3);
|
||||
} else if (sValue.endsWith("gb")) {
|
||||
bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 2)) * ByteSizeUnit.C3);
|
||||
} else if (sValue.endsWith("b")) {
|
||||
bytes = Long.parseLong(sValue.substring(0, sValue.length() - 1));
|
||||
} else {
|
||||
bytes = Long.parseLong(sValue);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue