I have a Money field in Sql server Table and mapping to double in hibernate. how to format as 999,999?(three to three separate)
for example: 45000.0 ---> 45,000
I have a Money field in Sql server Table and mapping to double in hibernate. how to format as 999,999?(three to three separate)
for example: 45000.0 ---> 45,000
I would suggest not to do this at the SQL or hibernate layer. You should handle this in you UI layer. You can use Java's DecimalFormat or see here for an example.
public class MyClass {
BigDecimal money;
public static final NumberFormat NUMBER_FORMAT = new DecimalFormat(",###");
@Column
public BigDecimal getMoney() {
return money;
}
@Transient
public String displayMoney(){
return NUMBER_FORMAT.format(money);
}
}