1

org.beanio用来解析固定长度的记录。

不幸的是,有些price价格的整数部分和小数部分分布到不同的位置。

问题:是否可以将两个@Fields 定义为一个值,并提取BigDecimal通孔的不同部分format

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

1 回答 1

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));
}
于 2016-11-10T09:59:19.157 回答