[英]How to use multiple @Field on the same value with beanio?
我正在使用org.beanio
來解析固定長度的記錄。
不幸的是,存在price
的整數部分和小數部分分布到不同位置的price
值。
問題:是否可以將兩個@Field
定義為一個值,並通過format
提取BigDecimal
不同部分?
@Field(at = 20, length = 6, format = ...<the integer part>)
@Field(at = 100, length = 2, format = ...<the fractional part>)
private BigDecimal price;
我不認為這是可能的,但您可以簡單地映射到其他 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));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.