(1) when int or double is converted to BigDecimal, the number of digits increases accordingly. To solve this problem, you can round the long type of double by using the self-write function round.
After conversion, convert to String, and then use new BigDecimal () to convert
Example: fosum = new BigDecimal (String. & #118 alueOf (round (uo1sum. double & #118 alue () + uo2sum. double & #118 alue (), 3 )))
(2) convert Time to characters
Java. util. Date date = new java. util. Date (databean. getTyrq (). getTime ());
SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd ");
Tyrq = sdf. format (date );
(3) convert the string to the Timestamp type
Public java. SQL. Timestamp strToTimestamp (String str ){
Java. SQL. Timestamp sdate = null;
If (str! = Null ){
If (str. trim (). length () = 8 ){
Str = str. substring () + "-" + str. substring () + "-" + str. substring );
}
Try {
DateFormat df = DateFormat. getDateInstance (DateFormat. DEFAULT, java. util. Locale. CHINA );
Java. util. Date date = df. parse (str );
Sdate = new java. SQL. Timestamp (date. getTime ());
} Catch (Exception e ){
E. printStackTrace ();
}
}
Return sdate;
}
(4) rounding the double type
Public double round (double v, int scale ){
If (scale <0 ){
Throw new IllegalArgumentException ("The scale must be a positive integer or zero ");
}
BigDecimal B = new BigDecimal (Double. toString (v ));
BigDecimal one = new BigDecimal ("1 ");
Return B. divide (one, scale,
<