一晃择、 用Java實現(xiàn)數(shù)字轉(zhuǎn)漢字
/**
* 數(shù)字轉(zhuǎn)大寫
* @param src 數(shù)字
* @return 返回大寫
*/
public static String int2chineseNum(int src) {
final String num[] = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
final String unit[] = {"", "十", "百", "千", "萬", "十", "百", "千", "億", "十", "百", "千"};
String dst = "";
int count = 0;
while(src > 0) {
dst = (num[src % 10] + unit[count]) + dst;
src = src / 10;
count++;
}
return dst.replaceAll("零[千百十]", "零").replaceAll("零+萬", "萬")
.replaceAll("零+億", "億").replaceAll("億萬", "億零")
.replaceAll("零+", "零").replaceAll("零$", "");
}
二、postgreSQL獲得兩個日期之間的時間差的天數(shù)
select date_part('day',cast(su.expire_time as TIMESTAMP)-cast(now() as TIMESTAMP)) from tb_ship_upload as su
三箕般、postgreSQL給查到的日期+天數(shù)
1. 無拼接時:
SELECT scan_time + '5 day' FROM tbl_temp_record
SELECT scan_time + '-5 day' FROM tbl_temp_record
2. 拼接字段時:
SELECT scan_time + (5 || ' day')::interval FROM tbl_temp_record
SELECT scan_time + ('-' || 5 || ' day')::interval FROM tbl_temp_record
-- 或
SELECT scan_time + 5*interval '1 day' FROM tbl_temp_record
SELECT scan_time + 5*interval '-1 day' FROM tbl_temp_record
列:
select (hspr.start_date+(hspr.package_days+hspr.package_extension_days||' day')::interval) result from health_service_purchase_record hspr
四辱匿、mybatis的<if test>
條件判斷
1. 在使用 MyBatis if 進行條件判斷時灶泵,一直報錯:
<if test="fwbdh != null and fwbdh == 'BAK'">
fwbdh=#{fwbdh}
<if>
2. MyBatis是使用的OGNL表達式來進行解析的硬猫,改成:
<if test='fwbdh != null and fwbdh == "BAK"'>
fwbdh=#{fwbdh}
<if>
同時碌上,MyBatis的if倚评、when里面的test表達式對參數(shù)進行判斷時浦徊,可以調(diào)用java的java.lang.String中定義的方法:
比如:
<if test="fwbdh != null and fwbdh != ''">
<choose>
<when test='fwbdh.indexOf(",") != -1'>
AND t.FWBDH in (${fwbdh})
</when>
<otherwise>
AND t.FWBDH like '%'+#{fwbdh}+'%'
</otherwise>
</choose>
</if>
五馏予、postgresql中將日期轉(zhuǎn)成字符串
to_char(time,'YYYY-MM-DD hh24:mi:ss') as time1,
to_char(time,'YYYY-MM-DD') as time2,
to_char(time,'YYYY-MM-DD hh:mi:ss') as time3
六、postgresql中比較字符串?dāng)?shù)字
使用to_number()轉(zhuǎn)成數(shù)字
SELECT max(to_number(attr_id,'9999999')) FROM base_dic_list;