Skip to content

Instantly share code, notes, and snippets.

Created September 28, 2012 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3802386 to your computer and use it in GitHub Desktop.
Save anonymous/3802386 to your computer and use it in GitHub Desktop.
public String getDescription(final Locale locale) {
String result;
final NumberFormat currency = NumberFormat.getCurrencyInstance(locale);
processing: {
if ((null == lowerBound) && (null == upperBound)) {
result = "All amounts";
break processing;
}
if (null == upperBound) {
if (BigDecimal.ZERO.equals(lowerBound)) {
result = "All amounts";
break processing;
}
result = currency.format(lowerBound) + "<= amount";
break processing;
}
if (null == lowerBound) {
result = "amount < " + currency.format(upperBound);
break processing;
}
result = currency.format(lowerBound) + " <= amount < " + currency.format(upperBound);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment