本文整理汇总了Java中org.kuali.rice.core.api.util.RiceKeyConstants.ERROR_PERCENTAGE属性的典型用法代码示例。如果您正苦于以下问题:Java RiceKeyConstants.ERROR_PERCENTAGE属性的具体用法?Java RiceKeyConstants.ERROR_PERCENTAGE怎么用?Java RiceKeyConstants.ERROR_PERCENTAGE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.kuali.rice.core.api.util.RiceKeyConstants
的用法示例。
在下文中一共展示了RiceKeyConstants.ERROR_PERCENTAGE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAsText
/**
* This overridden method converts
* <code>org.kuali.rice.core.api.util.type.KualiPercent</code> objects to the
* display string.
*
* @see java.beans.PropertyEditorSupport#getAsText()
*/
@Override
public String getAsText() {
Object value = this.getValue();
// Previously returned N/A
if (value == null)
return "";
String stringValue = "";
try {
if (value instanceof KualiDecimal) {
value = ((KualiDecimal) this.getValue()).bigDecimalValue();
}
BigDecimal bigDecValue = (BigDecimal) value;
bigDecValue = bigDecValue.setScale(PERCENTAGE_SCALE, BigDecimal.ROUND_HALF_UP);
stringValue = NumberFormat.getInstance().format(bigDecValue.doubleValue());
} catch (IllegalArgumentException iae) {
throw new FormatException("formatting", RiceKeyConstants.ERROR_PERCENTAGE, this.getValue().toString(), iae);
}
return stringValue +"%";
}
示例2: getAsText
/**
* This overridden method converts
* <code>org.kuali.rice.core.api.util.type.KualiPercent</code> objects to the
* display string.
*
* @see java.beans.PropertyEditorSupport#getAsText()
*/
@Override
public String getAsText() {
Object value = this.getValue();
// Previously returned N/A
if (value == null)
return "";
String stringValue = "";
try {
if (value instanceof KualiDecimal) {
value = ((KualiDecimal) this.getValue()).bigDecimalValue();
}
BigDecimal bigDecValue = (BigDecimal) value;
bigDecValue = bigDecValue.setScale(PERCENTAGE_SCALE, BigDecimal.ROUND_HALF_UP);
stringValue = NumberFormat.getInstance().format(bigDecValue.doubleValue());
} catch (IllegalArgumentException iae) {
throw new FormatException("formatting", RiceKeyConstants.ERROR_PERCENTAGE, this.getValue().toString(), iae);
}
return stringValue;
}
示例3: format
/**
* Returns a string representation of its argument, formatted as a percentage value.
*
* @return a formatted String
*/
@Override
public Object format(Object value) {
if (value == null) {
return "N/A";
}
String stringValue = "";
try {
if (value instanceof KualiDecimal) {
value = ((KualiDecimal)value).bigDecimalValue();
}
BigDecimal bigDecValue = (BigDecimal) value;
bigDecValue = bigDecValue.setScale(PERCENTAGE_SCALE, BigDecimal.ROUND_HALF_UP);
stringValue = NumberFormat.getInstance().format(bigDecValue.doubleValue());
}
catch (IllegalArgumentException iae) {
// begin Kuali Foundation modification
throw new FormatException("formatting", RiceKeyConstants.ERROR_PERCENTAGE, value.toString(), iae);
// end Kuali Foundation modification
}
return stringValue + " percent";
}