1.格式化數字
double amount= 111.0;
decimalformat df = new decimalformat("#,##0.00");
system.out.println(df.format(amount));
decimalformat decimal = new decimalformat("#.00");
string dlay_intr = decimal.format(ln_dlay_intr);
2.迭代器
for(iterator it = c.iterater(); it.hasnext(); )
for(int i=0; i源文件 <>
3.字串的擷取(用"|"作為分隔符時,前面要加"\\")
string arr = strr.split("\\|");
4.判斷乙個字串的最後乙個字元是否為「,」
"sdsdsd,".endswith(",")
5.stringutils的用法
stringutils.substring(rule, startindex,endindex + 1)//擷取字串
stringutils.repeat("0", orgcoderule.length()- 2 - orgcode.length())//重寫為0
stringutils.replace(rule, orgcoderule, orgcoderulevalue)//替換
6.indexof的用法
"010003,010004".indexof("010003") 返回值為0
7.去掉字串裡面的回車和換行符號
string sqlstring = "9021405430\n062228110165\r333";
system.out.println(sqlstring);
system.out.println(sqlstring.replaceall("\r", "").replaceall("\n", ""));
8.字串和日期互轉
字串轉日期
trycatch
(exception e)
trycatch
(exception e)
日期轉字串
******dateformat formatter = new ******dateformat("yyyymmddhhmmss");
string datestring = formatter.format(new date(system.currenttimemillis()));
string sdate = "20120207";
******dateformat dateformat = new ******dateformat("yyyymmdd");
try catch (exception e) {
e.printstacktrace();
java知識總結
包的訪問控制 子類 同個包內 不同包內 public y y y protect y y n private n n n i o和流 四個抽象類 讀寫位元組 inputstream outputstream 讀寫unicode字元 reader writer iterator arraylist v...
Java知識總結 for迴圈
在流程控制語句 條件語句和迴圈語句 中,對我造成最多困擾和模糊的就是for迴圈的多層巢狀,本篇文章通過例項分析巢狀式for迴圈。增強自己對for迴圈的理解。一,for語句概述 for語句的功能是為了重複執行某些語句,直到某個條件得到滿足。for語句格式如下 for 表示式1 表示式2 表示式3 迴圈...
java細小知識總結
public static void main string args private static inttest int i catch exception e finally 1 簡介 hibernate對資料庫結構提供了較為完成的封裝,主要物件導向,程式設計師甚至可以不需要太熟練掌握sql語...