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;
|
long bytes;
|
||||||
try {
|
try {
|
||||||
if (sValue.endsWith("b")) {
|
if (sValue.endsWith("k") || sValue.endsWith("K")) {
|
||||||
bytes = Long.parseLong(sValue.substring(0, sValue.length() - 1));
|
|
||||||
} else if (sValue.endsWith("k") || sValue.endsWith("K")) {
|
|
||||||
bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * ByteSizeUnit.C1);
|
bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * ByteSizeUnit.C1);
|
||||||
} else if (sValue.endsWith("kb")) {
|
} else if (sValue.endsWith("kb")) {
|
||||||
bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 2)) * ByteSizeUnit.C1);
|
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);
|
bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 1)) * ByteSizeUnit.C3);
|
||||||
} else if (sValue.endsWith("gb")) {
|
} else if (sValue.endsWith("gb")) {
|
||||||
bytes = (long) (Double.parseDouble(sValue.substring(0, sValue.length() - 2)) * ByteSizeUnit.C3);
|
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 {
|
} else {
|
||||||
bytes = Long.parseLong(sValue);
|
bytes = Long.parseLong(sValue);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue