本文整理汇总了Java中org.kuali.rice.core.api.util.RiceKeyConstants.ERROR_PHONE_NUMBER属性的典型用法代码示例。如果您正苦于以下问题:Java RiceKeyConstants.ERROR_PHONE_NUMBER属性的具体用法?Java RiceKeyConstants.ERROR_PHONE_NUMBER怎么用?Java RiceKeyConstants.ERROR_PHONE_NUMBER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.kuali.rice.core.api.util.RiceKeyConstants
的用法示例。
在下文中一共展示了RiceKeyConstants.ERROR_PHONE_NUMBER属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToObject
/**
* begin Kuali Foundation modification
* Removes formatting characters from the provided phone number and returns just the digits. Very lenient about formatting, but
* requires a ten-digit number.
* end Kuali Foundation modification
*/
@Override
protected Object convertToObject(String target) {
String digits = target.replaceAll("[^0-9]", "");
if (digits.length() != NUM_DIGITS)
{
// begin Kuali Foundation modification
throw new FormatException("parsing", RiceKeyConstants.ERROR_PHONE_NUMBER, target);
// end Kuali Foundation modification
}
return digits;
}
示例2: format
/**
* Returns its argument formatted as a phone number in the style:
* <p>
*
* <pre>
* (999) 999-9999
* </pre>
*/
@Override
public Object format(Object value) {
if (value == null) {
return null;
}
if (!(value instanceof String))
{
// begin Kuali Foundation modification
throw new FormatException("formatting", RiceKeyConstants.ERROR_PHONE_NUMBER, value.toString());
// end Kuali Foundation modification
}
// begin Kuali Foundation modification
String digits = ((String) value).replaceAll("[^0-9]", "");
if (digits.length() != NUM_DIGITS)
{
throw new FormatException("formatting", RiceKeyConstants.ERROR_PHONE_NUMBER, value.toString());
// end Kuali Foundation modification
}
StringBuffer buf = new StringBuffer("(");
buf.append(digits.substring(0, 3));
buf.append(") ");
buf.append(digits.substring(3, 6));
buf.append("-");
buf.append(digits.substring(6));
return buf.toString();
}