1 16 package org.apache.cocoon.woody.datatype.convertor; 17 18 import org.outerj.i18n.DecimalFormat; 19 20 import java.util.Locale ; 21 import java.text.ParseException ; 22 23 32 public class FormattingLongConvertor extends FormattingDecimalConvertor { 33 34 public FormattingLongConvertor() { 35 super(); 36 } 37 38 public Object convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) { 39 DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache); 40 try { 41 Number decimalValue = decimalFormat.parse(value); 42 if (decimalValue instanceof Long ) 43 return decimalValue; 44 else 45 return new Long (decimalValue.longValue()); 46 } catch (ParseException e) { 47 return null; 48 } 49 } 50 51 protected int getDefaultVariant() { 52 return INTEGER; 53 } 54 55 public Class getTypeClass() { 56 return Long .class; 57 } 58 } 59 | Popular Tags |