2016-09-13 8 views
1

私はorg.beanioを使用して固定長レコードを解析しています。同じ値で複数の@Fieldをbeanioで使用する方法は?

残念ながら、価格の整数と小数部分が異なる場所に配分されている値はpriceです。

質問:@Fieldを1つの値に定義し、BigDecimalの異なる部分をformatで抽出することはできますか?

@Field(at = 20, length = 6, format = ...<the integer part>) 
@Field(at = 100, length = 2, format = ...<the fractional part>) 
private BigDecimal price; 

答えて

1

私はそれが可能だとは思わないが、あなたは、単に2つの他のフィールドにマップし、値を計算することができ、

@Field(at = 20, length = 6) 
private Integer priceWholeAmt; 

@Field(at = 100, length = 2) 
private Integer priceChange; 

public BigDecimal getPrice(){ 
    return new BigDecimal(priceWholeAmt).add(new BigDecimal(priceChange/100)); 
} 
関連する問題