Fix small display problem when extension starts with 9

git-svn-id: https://zxing.googlecode.com/svn/trunk@1608 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-09-30 15:44:12 +00:00
parent 493ddb3a13
commit 5abef2f3aa

View file

@ -160,7 +160,7 @@ final class UPCEANExtensionSupport {
}
private static String parseExtension5String(String raw) {
String currency = null;
String currency;
switch (raw.charAt(0)) {
case '0':
currency = "£";
@ -169,18 +169,28 @@ final class UPCEANExtensionSupport {
currency = "$";
break;
case '9':
if ("99991".equals(raw)) {
// Reference: http://www.jollytech.com
if ("90000".equals(raw)) {
// No suggested retail price
return null;
} else if ("99991".equals(raw)) {
// Complementary
return "0.00";
} else if ("99990".equals(raw)) {
return "Used";
}
// Otherwise... unknown currency?
currency = "";
break;
default:
currency = "";
break;
}
int rawAmount = Integer.parseInt(raw.substring(1));
return currency + (rawAmount / 100) + '.' + (rawAmount % 100);
String unitsString = String.valueOf(rawAmount / 100);
int hundredths = rawAmount % 100;
String hundredthsString = hundredths < 10 ? "0" + hundredths : String.valueOf(hundredths);
return currency + unitsString + '.' + hundredthsString;
}
}