在某些国家/地区,有一个逗号用作小数点,但scala播放框架表单中的隐式转换仅接受点。所以我想在bigDecimal转换中添加自定义字符串。我在考虑类似的事情
Statement st = connect.createStatement();
String sql = "update StudentDatabaseS set RollNo = ?, FullName = ?, FatherName = ?, FatherCNIC = ?, DateOfBirth = ?, Class = ?, Address = ?, City = ?, Province = ? where RollNo = '"+Srollno+"'";
ResultSet rs = st.executeQuery(sql);
ps = connect.prepareStatement(sql);
ps.setInt(1, roll_mo);
ps.setString(2, name_mo);
ps.setString(3, Fname_mo);
ps.setString(4, fcnic_mo);
ps.setString(5, dob_mo);
ps.setInt (6, Class_mo);
ps.setString(7, add_mo);
ps.setString(8, city_mo);
ps.setString(9, prvnce_mo);
ps.executeUpdate();
但我应该把它放在哪里才能使它发挥作用?我的表单看起来像这样,它在控制器内部:
implicit object StringImplicits {
implicit def String2Decimal(value: String) = new BigDecimal(value.replace(",", "."))
}