UtilFuns.java 42.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541
package org.hqu.production_ms.util;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.text.DecimalFormat;

import java.net.URLEncoder;
import java.net.URLDecoder;
import java.util.Date;


/** UtilFuns is a JavaBean.  */
 public class UtilFuns {


  static public String newLine(){
  	return System.getProperty("line.separator"); 
  }
  

	/* 验证数组是否为空 */
	public static boolean arrayValid(Object[] objects) {
		if (objects != null && objects.length > 0) {
			return true;
		} else {
			return false;
		}
	}

	/* 验证list是否为空 */
	public boolean listValid(List list) {
		if (list != null && list.size() > 0) {
			return true;
		} else {
			return false;
		}
	}
  

  //获得年龄
  public int age(String dateStart, String dateEnd) throws Exception{
	  int yearStart = Integer.parseInt(dateStart.substring(0,4));
	  int yearEnd = Integer.parseInt(dateEnd.substring(0,4));
	  return yearEnd-yearStart;
  }
  
  //是否为奇数
  public boolean isOdd(int i){
	  if(i%2==0){
		  return false;
	  }else{
		  return true;
	  }
  }

  public String cutStr(String str,int len){
  	try{
  		str = str.substring(0,len);
  	}catch(Exception e){
  		return str;
  	}
  	return str;
  }
  
  //返回固定长度串,空白地方用空格填充 by tony 20110926
  public String fixSpaceStr(String str,int len){
	  StringBuffer sBuf = new StringBuffer();
	  try{
		  if(str.length()>len){
			  return str;
		  }else{
			  sBuf.append(str);
			  for(int i=0;i<(len-str.length());i++){
				  sBuf.append(" ");
			  }
			  return sBuf.toString();
		  }
	  }catch(Exception e){
		  return str;
	  }
  }
  
  public String fixSpaceStr(int number,int len){
	  return fixSpaceStr(String.valueOf(number),len);
  }
  
  //前缀空格
  public String prefixSpaceStr(String str,int len){
	  StringBuffer sBuf = new StringBuffer();
	  try{
		  if(str.length()>len){
			  return str;
		  }else{
			  for(int i=0;i<(len-str.length());i++){
				  sBuf.append(" ");
			  }
			  sBuf.append(str);
			  return sBuf.toString();
		  }
	  }catch(Exception e){
		  return str;
	  }
  }
  
  //截取字符,如果超过长度,截取并加省略号 by tony 20101108
  public String suspensionStr(String str,int len){
	  try{
		  str = str.substring(0,len) + "...";
	  }catch(Exception e){
		  return str;
	  }
	  return str;
  }

  //url get方式传递参数 by tony 20110328
  public static String joinUrlParameter(List<String> sList){
	  StringBuffer sBuf = new StringBuffer();
	  for(Iterator it = sList.iterator(); it.hasNext();){
		  sBuf.append("&").append(it.next()).append("=").append(it.next());
	  }
	  return sBuf.substring(1, sBuf.length());	//去掉第一个&符号
  }
  
  /** SplitStr 功能:返回分割后的数组
   * <br>输入参数:String str 设置返回系统时间样式
   * <br>输入参数:String SplitFlag 设置分割字符
   * <br>输出参数:string[] 返回分割后的数组
   * <br>作者:陈子枢
   * <br>时间:2003-9-7
   * <br>用法:
   */
/*
      String s[] = SplitStr("asd asd we sd"," ");
      for (int i=0;i<s.length;i++){
        System.out.println(s[i]);
      }
*/
  static public String[] splitStr(String str,String SplitFlag){
    int i =0;
    try{
      StringTokenizer st = new StringTokenizer(str, SplitFlag);
      String tokens[] = new String[st.countTokens()];
      //System.out.println(st.countTokens());
      while (st.hasMoreElements()) {
        tokens[i] = st.nextToken();
        //System.out.println(tokens[i]);
        i++;
      }
      return tokens;
    }catch(Exception e){
      return null;
    }
  }
  
  //类似google那样实现多个关键字的查询,关键字之间用空格或逗号隔开 by tony 20110523
  //支持的分隔符 英文逗号,中文逗号,空格
  public String[] splitFindStr(String str){
	if(str==null){
		return null;
	}
	String[] aStr = null;
	str = str.replaceAll(",", " ");		//英文逗号
	str = str.replaceAll(",", " ");		//中文逗号
	aStr = this.splitStr(str, " ");		//空格  
	return aStr;
 }
 
  /* 阶梯函数,例如,a,b,c 返回 a;a,b;a,b,c by tony 20110330 */
  static public String[] splitStair(String str,String SplitFlag){
	  try{
		  String[] _temp = splitStr(str, SplitFlag);
		  for(int i=1;i<_temp.length;i++){
			  _temp[i] = _temp[i-1]+SplitFlag+_temp[i];
		  }
		  return _temp;
	  }catch(Exception e){
		  return null;
	  }
  }

  /** SplitStr 功能:将数组合并为一个字符串
   * <br>输入参数:String aStr 要合并数组
   * <br>输入参数:String SplitFlag 设置分割字符
   * <br>输出参数:String 要合并数组
   * <br>作者:陈子枢
   * <br>时间:2004-1-9
   * <br>用法:
   */


  static public String joinStr(String[] aStr,String SplitFlag){
    StringBuffer sBuffer = new StringBuffer();
    if (aStr != null){
      for (int i=0;i<aStr.length;i++){
        sBuffer.append(aStr[i]).append(SplitFlag);
      }
      sBuffer.delete(sBuffer.length() - 1, sBuffer.length()); //去掉最后的分隔符 SplitFlag
    }else{
      sBuffer = sBuffer.append("");
    }
    return sBuffer.toString();
  }

  /* 链接,但中间无链接符号 add by tony 20100322 */
  static public String joinStr(String[] aStr){
    StringBuffer sBuffer = new StringBuffer();
    if (aStr != null){
      for (int i=0;i<aStr.length;i++){
        sBuffer.append(aStr[i]);
      }
    }else{
      sBuffer = sBuffer.append("");
    }
    return sBuffer.toString();
  }
  
  /** JoinStr 
   * <br>功能:将数组合并为一个字符串
   * <br>输入参数:String sPrefix 数组元素加的前缀
   * <br>输入参数:String sSuffix 数组元素加的后缀
   * <br>输入参数:String SplitFlag 设置分割字符
   * <br>输出参数:String 合并后的字符串
   * <br>作者:陈子枢
   * <br>时间:2005-3-17
   * <br>用法:
   */


  static public String joinStr(String[] aStr,String sPrefix,String sSuffix,String SplitFlag){
    StringBuffer sBuffer = new StringBuffer();
    if (aStr != null){
      for (int i=0;i<aStr.length;i++){
        sBuffer.append(sPrefix).append(aStr[i]).append(sSuffix).append(SplitFlag);
      }
      sBuffer.delete(sBuffer.length() - SplitFlag.length(), sBuffer.length()); //去掉最后的分隔符 SplitFlag
    }else{
      sBuffer = sBuffer.append("");
    }
    return sBuffer.toString();
  }
  
  /* 返回用于in查询的串  'x','y' */
  static public String joinInStr(String[] aStr){
	  StringBuffer sBuffer = new StringBuffer();
	  if (aStr != null){
		  for (int i=0;i<aStr.length;i++){
			  sBuffer.append("'").append(aStr[i]).append("'").append(",");
		  }
		  sBuffer.delete(sBuffer.length() - 1, sBuffer.length());
	  }else{
		  sBuffer = sBuffer.append("");
	  }
	  return sBuffer.toString();
  }

  /* 链接,但中间无链接符号 add by tony 20100322 */
  static public String joinStr(String[] aStr,String sPrefix,String sSuffix){
    StringBuffer sBuffer = new StringBuffer();
    if (aStr != null){
      for (int i=0;i<aStr.length;i++){
        sBuffer.append(sPrefix).append(aStr[i]).append(sSuffix);
      }
    }else{
      sBuffer = sBuffer.append("");
    }
    return sBuffer.toString();
  }

  /* 链接len(s)个symbol符号 add by tony 20100407 */
  static public String joinStr(String s, String symbol){
	  StringBuffer sBuf = new StringBuffer();
	  for (int i=0;i<s.length();i++){
		  sBuf.append(symbol);
      }
	  return sBuf.toString();
  }
  
  static public String joinStr(int len, String symbol){
	  StringBuffer sBuf = new StringBuffer();
	  for (int i=0;i<len;i++){
		  sBuf.append(symbol);
      }
	  return sBuf.toString();
  }  
  
  /** SysTime 功能:返回系统时间
 * <br>输入参数:int style 设置返回系统时间样式
 * <br>输出参数:string 返回系统时间样式
 * <br>作者:陈子枢
 * <br>时间:2003-6-24
 * <br>存在问题:中文乱码,但JSP中显示正常。
 */
  static public String SysTime(String strStyle){
    String s = "";
    if (strStyle.compareTo("")==0){
    	strStyle = "yyyy-MM-dd HH:mm:ss";	//default
    }
    java.util.Date date=new java.util.Date();
    SimpleDateFormat dformat=new SimpleDateFormat(strStyle);
    s = dformat.format(date);
    return s;
  }

  static public String sysTime(){
    String s = "";
    java.util.Date date=new java.util.Date();
    SimpleDateFormat dformat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    s = dformat.format(date);
    return s;
  }

  static public String sysDate(){
    String s = "";
    java.util.Date date=new java.util.Date();
    SimpleDateFormat dformat=new SimpleDateFormat("yyyy-MM-dd");
    s = dformat.format(date);
    return s;
  }


  /* add by tony 20091113 */
  public static boolean isNull(Object obj){
    try{
      if(obj==null){
    	  return true;
      }
      return false;
    }catch(Exception e){
      return false;
    }
  }
  
  public static boolean isNotNull(Object obj){
    try{
      if(obj==null){
    	  return false;
      }
      return true;
    }catch(Exception e){
      return true;
    }
  }  

  public static boolean isEmpty(String str){
    try{
      if(str==null || str.equals("null") || str.equals("")){
    	  return true;
      }
      return false;
    }catch(Exception e){
      return false;
    }
  }
  
  public static boolean isEmpty(String strs[]){
	  try{
		  if(strs==null || strs.length<=0){
			  return true;
		  }
		  return false;
	  }catch(Exception e){
		  return false;
	  }
  }

  public static boolean isNotEmpty(String str){
    try{
      if(str==null || str.equals("null") || str.equals("")){
    	  return false;
      }
      return true;
    }catch(Exception e){
      return true;
    }
  }

  public static boolean isNotEmpty(Object obj){
    try{
      if(obj==null || obj.toString().equals("null") || obj.toString().equals("")){
    	  return false;
      }
      return true;
    }catch(Exception e){
      return true;
    }
  }
  
  public static boolean isNotEmpty(List obj){
	  try{
		  if(obj==null || obj.size()<=0){
			  return false;
		  }
		  return true;
	  }catch(Exception e){
		  return true;
	  }
  }
  
  /** 功能:用于转换为null的字段。
   * <br>入参:String strvalue 设置要转换的字符串
   * <br>出参:不为“null”的返回原串;为“null”返回""。
   * <br>作者:陈子枢
   * <br>时间:2003-9-16
   * <p>用法:optionFuns.convertNull(String.valueOf(oi.next()))</p>
   */
  public static String convertNull(String strvalue)
  {
    try{
      if(strvalue.equals("null") || strvalue.length()==0){
        return "";
      }else{
        return strvalue.trim();
      }
    }catch(Exception e){
      return "";
    }
  }

  public static String[] convertNull(String[] aContent)
  {
    try{
      for(int i=0;i<aContent.length;i++){
        if(aContent[i].toLowerCase().compareTo("null")==0){
          aContent[i] = "";
        }
      }
      return aContent;
    }catch(Exception e){
      return null;
    }
  }
    
  public static String convertNull(Object o)
  {
    try{
      String strvalue = String.valueOf(o);
      if(strvalue.equals(null) || strvalue.equals("null") || strvalue.length()==0){
        return "";
      }else{
        return strvalue.trim();
      }
    }catch(Exception e){
      return "";
    }
  }
  
  //将为null的数据转为0,用在数值的值从数据库中读出的情况
  public static int ConvertZero(Object o)
  {
    try{
      String s = convertNull(o);
      if(s==""){
        return 0;
      }else{
        return Integer.parseInt(s);
      }
    }catch(Exception e){
      return 0;
    }
  }
  
  //将为null的数据转为0,用在数值的值从数据库中读出的情况
  public static int cvtPecrent(Object o)
  {
    try{
      String s = convertNull(o);
      if(s==""){
        return 0;
      }else{
        return Integer.parseInt(s);
      }
    }catch(Exception e){
      return 0;
    }
  }  
  
  //if 0 then return "";
  public static String FormatZero(Object o)
  {
    try{
      String s = convertNull(o);
      if(s.compareTo("")==0){
        return "";
      }else{
        return String.valueOf(s);
      }
    }catch(Exception e){
      return "";
    }
  }
  
  //if 0 then return "";
  public static String FormatZero(String s)
  {
    try{
      if(s.compareTo("0")==0){
        return "";
      }else{
        return s;
      }
    }catch(Exception e){
      return "";
    }
  }
  
  //patter="####.000"
  public static String FormatNumber(Object o,String patter)
  {
  	double d = 0;
    try {
      d = Double.parseDouble(String.valueOf(o));
      DecimalFormat df = new DecimalFormat(patter);
      return df.format(d);
    }
    catch (Exception e) {
    	System.out.println(e.getMessage());
       	return "";
    }
  }

  
  //patter="####.00"
  public static String FormatNumber(String s)
  {
  	double d = 0;
    try {
      d = Double.parseDouble(s);
      DecimalFormat df = new DecimalFormat(",###.00");
      return df.format(d);
    }
    catch (Exception e) {
    	System.out.println(e.getMessage());
    	return "";
    }
  }
  
  //只用在表格的输出
  public static String ConvertTD(String strvalue)
  {
    try{
      strvalue = strvalue.trim();
      if(strvalue.equals("null") || strvalue.length()==0){
        return "&nbsp;";
      }else{
        return strvalue;
      }
    }catch(Exception e){
      return "&nbsp;";
    }
  }

  public static String ConvertSpaceTD(Object o)
  {
    try{
      String strvalue = String.valueOf(o);
      strvalue = strvalue.trim();
      if(strvalue.equals("null") || strvalue.length()==0){
        return "&nbsp;";
      }else{
        return " " + strvalue.trim();
      }
    }catch(Exception e){
      return "&nbsp;";
    }
  }
  
  /*
    只转中文,不处理null
    读取记录时去掉数据两边的空格;而录入数据时,维持用户的输入,哪怕用户多输入了空格
    原因在于有时可能用户有意输入空格。例如:备注字段原来有内容,现在用户想清空。
  */
  public static String ConvertCH(String strvalue)
  {
    System.out.println("ConvertCH:"+strvalue);
    try{
      if(strvalue==null){
        return "null";
      }else if(strvalue.length()==0){
        return "";      
      }else{
        strvalue = new String(strvalue.getBytes("ISO8859_1"), "GB2312");
        return strvalue;
      }
    }catch(Exception e){
      return "";
    }
  }
  
  public static String ConvertCStr(String strvalue)
  {
    try{
      strvalue = convertNull(strvalue);
      if(strvalue.equals("")){
        return "";
      }else{
        strvalue = new String(strvalue.getBytes("ISO8859_1"), "GB2312");
        return strvalue;
      }
    }catch(Exception e){
      return "";
    }
  }

  public static String ConvertCStr(Object o)
  {
    String strvalue = "";
    try{
      strvalue = String.valueOf(o);
      strvalue = convertNull(strvalue);
      if(strvalue.equals("")){
        return "";
      }else{
        strvalue = new String(strvalue.getBytes("ISO8859_1"), "GB2312");
        return strvalue;
      }
    }catch(Exception e){
      System.out.println("ConvertCStr:" + e.toString());
      return "";
    }
  }
  
  /**
   *UrlEncoder 进行URL编码
   */
    public String UrlEncoder(String s)
    {
        String s1 = "";
        if(s == null)
            return "";
        try
        {
            s1 = URLEncoder.encode(s);
        }
        catch(Exception e)
        {
            System.out.println("URL Encoder :" + e.toString());
            s1 = "";
        }
        return s1;
    }

  /**
   *URLDecoder 进行URL解码
   */
    public String UrlDecoder(String s)
    {
        String s1 = "";
        if(s == null)
            return "";
        try
        {
            s1 = URLDecoder.decode(s);
        }
        catch(Exception e)
        {
            System.out.println("URL Encoder :" + e.toString());
            s1 = "";
        }
        return s1;
    }
    
  /**
   * 将字符串转化成首字母大写,其余字母小写的格式
   * @param source 传入字符串
   * @return String
   */
  public static String format_Aaa(String source) {

    if (source==null) return null;
    if (source.equals("")) return "";

    String a;
    a = source.substring(0, 1);
    a = a.toUpperCase();
    return a + source.substring(1);

  }
  
  /**
   * 将字符串转换成Long型
   * @param param 传入字符串
   * @return 长整形
   */
  public static long parseLong(String param) {
    long l=0;
    try {
      l = Long.parseLong(param);
    }
    catch (Exception e) {
    }

    return l;
  }

  /**
   * 将字符串转换成Float型
   * @param param 传入字符串
   * @return 浮点型
   */
  public static float parseFloat(String param) {
    float l=0;
    try {
      l = Float.parseFloat(param);
    }
    catch (Exception e) {
    }

    return l;
  }

  /**
   * 将字符串转换成Integer型
   * @param param 传入字符串
   * @return 整形
   */
  public static int parseInt(String param) {
    int l=0;
    try {
      l = Integer.parseInt(param);
    }
    catch (Exception e) {
    }

    return l;
  }


	public static Date parseDate(String currDate, String format) {
	    SimpleDateFormat dtFormatdB = null;
	    try {
	        dtFormatdB = new SimpleDateFormat(format);
	        return dtFormatdB.parse(currDate);
	    }catch (Exception e){
	        dtFormatdB = new SimpleDateFormat("yyyy-MM-dd");
	        try {
	            return dtFormatdB.parse(currDate);
	        }catch (Exception ex){}
	    }
	    return null;
	}

	public static Date parseDate(String currDate) {
	    SimpleDateFormat dtFormatdB = null;
	    dtFormatdB = new SimpleDateFormat("yyyy-MM-dd");
	    try {
	        return dtFormatdB.parse(currDate);
	    }catch (Exception e){
	        try {
	            return dtFormatdB.parse(currDate);
	        }catch (Exception ex){}
	    }
	    return null;
	}
	
	public static Date parseTime(String currDate, String format) {
	    SimpleDateFormat dtFormatdB = null;
	    try {
	        dtFormatdB = new SimpleDateFormat(format);
	        return dtFormatdB.parse(currDate);
	    }catch (Exception e){
	        dtFormatdB = new SimpleDateFormat("HH:mm:ss");
	        try {
	            return dtFormatdB.parse(currDate);
	        }catch (Exception ex){}
	    }
	    return null;
	}

	public static Date parseDateTime(String currDate, String format) {
	    SimpleDateFormat dtFormatdB = null;
	    try {
	        dtFormatdB = new SimpleDateFormat(format);
	        return dtFormatdB.parse(currDate);
	    }catch (Exception e){
	        dtFormatdB = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	        try {
	            return dtFormatdB.parse(currDate);
	        }catch (Exception ex){}
	    }
	    return null;
	}
	
  /**
   * 将字符串转换成Double型
   * @param param 传入字符串
   * @return double型
   */
  public static double parseDouble(String param) {
    double l=0;
    try {
      l = Double.parseDouble(param);
    }
    catch (Exception e) {
    }

    return l;
  }

  /**
   * s是否存在ArrayList中,存在返回数组下标,不存在返回-1
   */
  public static int existElements(String s,ArrayList aList) {
    try{
      for (int i = 0; i < aList.size(); i ++) {
        if (s.equals(aList.get(i))){
          return i;
        }
      }
    }catch(Exception e){   }
    return -1;
  }

  /**
   * s是否存在String数组中,存在返回数组下标,不存在返回-1
   */
  public static int existElements(String s,String[] a) {
    try{
      for (int i = 0; i < a.length; i ++) {
        if (s.compareTo((a[i].trim()))==0){  
          return i;
        }
      }
    }catch(Exception e){   }
    return -1;
  }
  
  /**
   * 判断对象o是否存在于set对象集合中 create by tony 20090611
   */  
  public static boolean existElements(Object o, Set set) {
	  boolean isExists = false;
	  Iterator it = set.iterator();
	  while(it.hasNext())
	  {
	       Object obj = it.next();
	       if(o.equals(obj))
	       {
	    	   isExists=true;
	    	   break;
	       }
	  }
	  return isExists;
  }

  /**
   * s是否存在ArrayList中,存在返回数组下标,不存在返回-1
   */
  public static int IsIndexOfElements(String s,ArrayList aList) {
    try{
      String s1 = "";
      for (int i = 0; i < aList.size(); i ++) {
        s1 = String.valueOf(aList.get(i));
        if (s1.indexOf(s)!=-1){
          return i;
        }
      }
    }catch(Exception e){   }
    return -1;
  }
  
  /**
   * 将ArrayList转换为一维String数组,并把其中的null换成空字符串
   * @param aList 传入的Arraylist
   */
  public String[] ArrayListToString(ArrayList aList) {
    String[] s = new String[aList.size()];
    for (int i = 0; i < aList.size(); i ++) {
      s[i] = this.convertNull(aList.get(i));
    }
    return s;
  }
  
  
  /**
   * 将数组中的null换成空字符串
   * @param al 传入的Arraylist,同时也是输出结果
   */
  public static void formatArrayList(ArrayList al) {

    for (int i = 0; i < al.size(); i ++) {
      if (al.get(i) == null)
        al.set(i, "");
    }

  }

    /** ComboList 功能:选定在下拉列表框中与查找到数据,相符的那一项内容
     * <br>输入参数:String CurrentValue 查找出的数据库中的数据
     *               String[] content 需要输出的所有下拉列表框的内容
     * <br>输出参数:返回下拉列表
      * <br>注意事项:values为0开始,而且中间不能断开
     */
    public String ComboList(String CurrentValue, String[] content) {
      int i = 0;
      StringBuffer sBuf = new StringBuffer();
      String selected = " selected";
      try{
        sBuf.append("<option value='' selected>--请选择--</option>");
        for (i = 0; i < content.length; i++) {
          sBuf.append("\n<option value='").append(i).append("'");
          if (CurrentValue.compareTo(String.valueOf(i)) == 0) {
            sBuf.append(selected);
          }
          sBuf.append(">").append(content[i]).append("</option>");
        }
        return sBuf.toString();
      }catch(Exception e){
        return "";
      }
    }

    public String ComboListMust(String CurrentValue, String[] content) {
      int i = 0;
      StringBuffer sBuf = new StringBuffer();
      String selected = " selected";
      try{
        for (i = 0; i < content.length; i++) {
          sBuf.append("\n<option value='").append(i).append("'");
          if (CurrentValue.compareTo(String.valueOf(i)) == 0) {
            sBuf.append(selected);
          }
          sBuf.append(">").append(content[i]).append("</option>");
        }
        return sBuf.toString();
      }catch(Exception e){
        return "";
      }
    }
    
    /** ComboList 功能:选定在下拉列表框中与查找到数据,相符的那一项内容
     * <br>输入参数:String CurrentValue 查找出的数据库中的数据
     *               String[] values  需要输出的所有下拉列表框的内容所对应的值
     *               String[] content 需要输出的所有下拉列表框的内容
     * <br>输出参数:返回下拉列表
     * <br>修改:陈子枢
     * <br>修改时间:2003-9-4
     * <br>注意事项:values和content数组个数必须相同.适合从数据库中取值
	<%
	  String[] aContextOPERATE_TYPE = {"定检","轮换","抽检"};
	  out.print(optionFuns.ComboList("",aContextOPERATE_TYPE,aContextOPERATE_TYPE));
	%>
     */
    public String ComboList(String CurrentValue,String[] values, String[] content) {
      int i = 0;
      StringBuffer sBuf = new StringBuffer();
      String selected = " selected";

      try{
    	if(CurrentValue==null){
    		CurrentValue = "";
    	}
        sBuf.append("<option value='' selected>--请选择--</option>");
        for (i = 0; i < content.length; i++) {
          sBuf.append("<option value='").append(values[i]).append("'");
          if (CurrentValue.compareTo(values[i]) == 0) {
            sBuf.append(selected);
          }
          sBuf.append(">").append(content[i]).append("</option>");
        }
        return sBuf.toString();
      }catch(Exception e){
        return "";
      }
    }

    public String ComboListMust(String CurrentValue,String[] values, String[] content) {
      int i = 0;
      StringBuffer sBuf = new StringBuffer();
      String selected = " selected";

      try{
        for (i = 0; i < content.length; i++) {
          sBuf.append("<option value='").append(values[i]).append("'");
          if (CurrentValue.compareTo(values[i]) == 0) {
            sBuf.append(selected);
          }
          sBuf.append(">").append(content[i]).append("</option>");
        }
        return sBuf.toString();
      }catch(Exception e){
        return "";
      }
    } 
    
  /** StrToTimestamp 功能:将字符串转换为Timestamp 。
   * <br>输入参数:String timestampStr 设置要转换的字符串
   *              String pattern 要转换的format
   * <br>输出参数:如果格式正确返回格式后的字符串。
   *              不正确返回系统日期。
   * <br>作者:陈子枢
   * <br>时间:2003-8-26
   */
  public static Timestamp StrToTimestamp(String timestampStr,String pattern) throws ParseException {
    java.util.Date date = null;
    SimpleDateFormat format = new SimpleDateFormat(pattern);
    try {
      date = format.parse(timestampStr);
    } catch (ParseException ex) {
      throw ex;
    }
    return date == null ? null : new Timestamp(date.getTime());
  }

  //ex:utilFuns.StrToDateTimeFormat("2005-12-01 00:00:00.0,"yyyy-MM-dd")
  public static String StrToDateTimeFormat(String timestampStr,String pattern) throws ParseException {
    String s ="";
    try{
      s = String.valueOf(StrToTimestamp(timestampStr, pattern));
      s = s.substring(0,pattern.length());
    }catch(Exception e){ }
    return s;
  }

  //ex:utilFuns.StrToDateTimeFormat("2005-12-01 00:00:00.0,"yyyy-MM-dd")
  public static String dateTimeFormat(Date date,String pattern) throws ParseException {
    String s ="";
    try{
        SimpleDateFormat dformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        s = dformat.format(date);
        s = String.valueOf(StrToTimestamp(s, pattern));
        s = s.substring(0,pattern.length());
    }catch(Exception e){ }
    return s;
  }
  public static String dateTimeFormat(Date date) throws ParseException {
	  String s ="";
	  try{
		  SimpleDateFormat dformat = new SimpleDateFormat("yyyy-MM-dd");
		  s = dformat.format(date);
		  s = String.valueOf(StrToTimestamp(s, "yyyy-MM-dd"));
		  s = s.substring(0,"yyyy-MM-dd".length());
	  }catch(Exception e){ }
	  return s;
  }
  
  //add by tony 20100228 转换中文 格式必须为:"yyyy-MM-dd HH:mm:ss"的一部分
  public static String formatDateTimeCN(String date) throws ParseException {
	  String s ="";
	  try{
		  if(UtilFuns.isEmpty(date)){
			  return "";
		  }
		  if(date.indexOf(".")>-1){
			  date = date.substring(0, date.indexOf("."));
		  }
		  if(date.length()==4){			//yyyy
			  s = date+"年";
		  }else if(date.length()==7){	//yyyy-MM
			  s = date.replaceAll("-0", "-").replaceFirst("-", "年")+"月";
		  }else if(date.length()==10){	//yyyy-MM-dd
			  s = date.replaceAll("-0", "-").replaceFirst("-", "年").replaceFirst("-", "月")+"日";
		  }else if(date.length()==2){	//HH
			  s = date+"时";
		  }else if(date.length()==5){	//HH:mm
			  s = date.replaceAll(":0", ":").replaceFirst(":", "时")+"分";
		  }else if(date.length()==8){	//HH:mm:ss
			  s = date.replaceAll(":0", ":").replaceFirst(":", "时").replaceFirst(":", "分")+"秒";
		  }else if(date.length()==13){	//yyyy-MM-dd HH
			  s = date.replaceAll("-0", "-").replaceFirst("-", "年").replaceFirst("-", "月").replaceAll(" 0", " ").replaceFirst(" ", "日")+"时";
		  }else if(date.length()==16){	//yyyy-MM-dd HH:mm
			  s = date.replaceAll("-0", "-").replaceFirst("-", "年").replaceFirst("-", "月").replaceAll(" 0", " ").replaceFirst(" ", "日").replaceAll(":0", ":").replaceFirst(":", "时")+"分";
		  }else if(date.length()==19){	//yyyy-MM-dd HH:mm:ss
			  s = date.replaceAll("-0", "-").replaceFirst("-", "年").replaceFirst("-", "月").replaceAll(" 0", " ").replaceFirst(" ", "日").replaceAll(":0", ":").replaceFirst(":", "时").replaceFirst(":", "分")+"秒";
		  }
		  s = s.replaceAll("0[时分秒]", "");	//正则 0时0分0秒的都替换为空
	  }catch(Exception e){ }
	  
	  return s;
  }
  
  //add by tony 2011-07-26 返回英文格式日期 oct.10.2011
  public static String formatDateEN(String date) throws ParseException {
	  String s ="";
	  int whichMonth = 1;
	  try{
		  if(UtilFuns.isEmpty(date)){
			  return "";
		  }
		  String[] aString = date.replaceAll("-0", "-").split("-");
		  whichMonth = Integer.parseInt(aString[1]);
		  if(whichMonth==1){
			  s = "Jan";
		  }else if(whichMonth==2){
			  s = "Feb";
		  }else if(whichMonth==3){
			  s = "Mar";
		  }else if(whichMonth==4){
			  s = "Apr";
		  }else if(whichMonth==5){
			  s = "May";
		  }else if(whichMonth==6){
			  s = "Jun";
		  }else if(whichMonth==7){
			  s = "Jul";
		  }else if(whichMonth==8){
			  s = "Aug";
		  }else if(whichMonth==9){
			  s = "Sept";
		  }else if(whichMonth==10){
			  s = "Oct";
		  }else if(whichMonth==11){
			  s = "Nov";
		  }else if(whichMonth==12){
			  s = "Dec";
		  }
		  s = s+"."+aString[2]+","+aString[0];
		  
	  }catch(Exception e){ }
	  
	  return s;
  }

  //返回年月格式 2010-7
  public String formatShortMonth(String strDate){
	  return strDate.substring(0,7).replaceAll("-0", "-");
  }
  
  //返回年月格式 2010-07
  public String formatMonth(String strDate){
	  return strDate.substring(0,7);
  }
  
  
  
  //删除最后1个字符
  public static String delLastChar(String s){
    try{
      if(s.length()>0){
        s = s.substring(0,s.length()-1);  
      }      
    }catch(Exception e){
      return "";
    }
    return s;
  }
  
  //删除最后len个字符
  public static String delLastChars(String s,int len){
    try{
      if(s.length()>0){
        s = s.substring(0,s.length()-len);  
      }      
    }catch(Exception e){
      return "";
    }
    return s;
  }
  
  //替换网页用字符-配合FCKEditor使用 .replaceAll("'","&apos;") //for viewpage
  public String htmlReplaceAll(String s){
	  try{
		  StringBuffer sBuf = new StringBuffer();
		  //.replaceAll("\\\\","\\\\\\\\").replaceAll("&","&amp;")
		  sBuf.append(s.replaceAll(" ","&nbsp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll("\"","&quot;").replaceAll("\n","<br\\>"));
		  return sBuf.toString();
	  }catch(Exception e){
		  return "";
	  }
  }
  
  //for viewpage by jstl/make html
  public static String htmlNewline(String s){
	  try{
		  //如不替换空格,html解释时会自动把多个空格显示为一个空格,这样当我们通过空格来布局时就出现textarea中和html页面展现不一致的情况 tony
		  //s.replaceAll(" ","&nbsp;") 不能进行空格的替换,否则页面内容中如果有<img src="xxx.jpg" \>等标签,内容就会显示乱;<img&nbsp;src="xxx.jpg"nbsp;\>
		  return s.replaceAll(" ","&nbsp;").replaceAll("\n","<br\\>");  
	  }catch(Exception e){
		  return "";
	  }
  }
  

  /** getPassString 功能:用于转换为后几位的为*。
   * <br>输入参数:String strvalue 设置要转换的字符串
   *              int Flag 位数。
   * <br>输出参数:。
   * <br>作者:范波
   * <br>时间:2006-8-7
   * <br>存在问题:
   * <br>用法:
   *          <%=utilFuns.ConvertString("abcdef",3)%>
   */
  public static String getPassString( String strvalue, int Flag ) {
    try {
      if ( strvalue.equals("null") || strvalue.compareTo("")==0){
        return "";
      } else {
        int intStrvalue = strvalue.length();
        if ( intStrvalue > Flag ) {
          strvalue = strvalue.substring( 0, intStrvalue - Flag );

        }
        for ( int i = 0; i < Flag; i++ ) {
          strvalue = strvalue + "*";
        }

        //System.out.print( "strvalue:" + strvalue );
        return strvalue;
      }
    }
    catch (Exception e) {
      return strvalue;
    }
  }
  
 /** getPassString 功能:用于转换为后几位的为*。
 * <br>输入参数:String strvalue 设置要转换的字符串
 *              int Flag 起位数。
 *              int sFlag 末位数。 
 * <br>输出参数:。
 * <br>作者:范波
 * <br>时间:2006-8-7
 * <br>存在问题:
 * <br>用法:
 *          <%=optionFuns.getPassString(String.valueOf(oi.next()),3)%>
 */
public static String getPassString( String strvalue, int Flag, int sFlag ,int iPassLen ) {
  try {
    
    if ( strvalue.equals( "null" ) ) {
      return "";
    } else {
      String strvalue1="";
      String strvalue2="";
      int intStrvalue = strvalue.length();
      if(sFlag>=Flag){
        if ( intStrvalue > Flag ) {
          strvalue1 = strvalue.substring( 0,  Flag );
          strvalue2 = strvalue.substring(  sFlag, intStrvalue );
        } else {
          strvalue1 = "";
          strvalue2 = "";
        }
        for ( int i = 0; i < iPassLen; i++ ) {
          strvalue1 = strvalue1 + "*";
        }
        strvalue=strvalue1+strvalue2;
      }
      //System.out.print( "strvalue:" + strvalue );
      return strvalue;
    }
  }
  catch (Exception e) {
    return strvalue;
  }
  } 
  
  
  /* 
	by czs 2006-8-17
	OPTION:
		取得字符串iStartPos位置到iEndPos位置,将中间这部分转换iPatternLen个sPattern
	EXSAMPLE:
		getPatternString("CHEN ZISHU",5,7,"*",3)
		RESULT: CHEN ***SHU

		getPatternString("CHEN ZISHU",10,0,".",3)
		RESULT: CHEN******

  */
  public static String getPatternString( String s, int iStartPos, int iEndPos, String sPattern, int iPatternLen ) {
    try {
	  if (iEndPos==0) {
		iEndPos = s.length();
	  }
	  
	  String sStartStr = "";
	  String sCenterStr = "";
	  String sEndStr = "";
	  
      if ( s.equals("null")){
        return "";
      } else {
        int ints = s.length();
        if ( ints > iStartPos ) {
          sStartStr = s.substring( 0, iStartPos );
        }else{
          return s;
        }
		if ( ints > iEndPos) {
          sEndStr = s.substring( iEndPos, ints );
		}
        for ( int i = 0; i < iPatternLen; i++ ) {
          sCenterStr = sCenterStr + sPattern;
        }
        return sStartStr + sCenterStr + sEndStr;
      }
    }
    catch (Exception e) {
      System.out.println(e);
      return s;
    }
  }

  public static String getPatternString( String s, int iStartPos, String sPattern, int iPatternLen ) {
    return getPatternString(s,iStartPos,0,sPattern,iPatternLen);
  }

  public static String getPatternString( String s, int iStartPos, String sPattern ) {
    return getPatternString(s,iStartPos,0,sPattern,3);
  }

  
    /** getQQString 功能:用于转换为后几位的为*。
* <br>输入参数:String strvalue 设置要转换的字符串
*               
* <br>输出参数:。
* <br>作者:范波
* <br>时间:2006-8-7
* <br>存在问题:
* <br>用法:
*          <%=optionFuns.getQQString(String.valueOf(oi.next()))%>
*/
public static String getQQString( String strvalue ) {
	try {
	  String QQ="";
	  if ( strvalue.equals("") ) {
	    return "";
	  } else {
	     QQ="<img src=\"http://wpa.qq.com/pa?p=1:"+strvalue
	        +":4\">"
	        +" <SPAN title=\"有事叫我!\" style=\"CURSOR: hand\""
	        +" onclick=\"window.open('http://wpa.qq.com/msgrd?V=1&amp;Uin="+strvalue
	        +"&amp;Site=21pan&amp;Menu=yes')\">"+strvalue+"</SPAN>";
	    }
	    strvalue=QQ;
	    //System.out.print( "strvalue:" + strvalue );
	    return strvalue;
	  
	}
	
	catch (Exception e) {
	  return strvalue;
	}
}

	public String getNoExistString(String allString, String existString){
		return this.getNoExistString(this.splitStr(allString, ","), existString);
	}
	
	/* 返回existString中的每个字串不在allString中的 */
	public String getNoExistString(String[] allString, String existString){
		existString = existString + ",";
		if(allString==null&&allString.length==0){
			return "";
		}
		StringBuffer sBuf = new StringBuffer();
		for(int i=0;i<allString.length;i++){
			if(existString.indexOf(allString[i])==-1){
				sBuf.append(allString[i]).append(",");
			}
		}
		if(sBuf.length()>1){
			sBuf.delete(sBuf.length()-1, sBuf.length());
		}
		return sBuf.toString();
	}
	
  public static void main(String[] args) throws Exception {

//	  
//	  
//	  java.util.List aList = new ArrayList();
//	  System.out.println(UtilFuns.isNotEmpty(aList));
//	  
//	  System.out.println(uf.formatDateTimeCN("2011"));
//	  System.out.println(uf.formatDateTimeCN("2011-01"));
//	  System.out.println(uf.formatDateTimeCN("2011-01-02"));
//	  System.out.println(uf.formatDateTimeCN("2011-01-02 03"));
//	  System.out.println(uf.formatDateTimeCN("2011-01-02 13:05"));
//	  System.out.println(uf.formatDateTimeCN("2011-01-02 13:05:05"));
//	  System.out.println(uf.formatDateTimeCN("03"));
//	  System.out.println(uf.formatDateTimeCN("13:05"));
//	  System.out.println(uf.formatDateTimeCN("13:05:05"));
	  
//	  UtilFuns uf = new UtilFuns();
//	  System.out.println(uf.getNoExistString("1,2,3", "1,2,3,4"));
//	  System.out.println(uf.getNoExistString("安全,生产,营销", "生产,营销"));
//	  System.out.println("finish!");
	  
//	  Set<String> set = new HashSet<String>();
//	  set.add("abc");
//	  set.add("xyz"); 
//	  set.add("abc");  
//	  for(Iterator<String> it = set.iterator();it.hasNext();){
//	   System.out.println(it.next());   
//	  } 
	
  	/*
    System.out.println(SysTime("yyyy-MM-dd"));
    System.out.println(SysTime("yyyy-MM-dd HH:mm:ss"));
    
    System.out.println(Double.parseDouble("12.11"));
    System.out.println(FormatNumber("12.11000000000f"));
    
    System.out.println(getPatternString("CHEN ZISHU",8,0,".",3));
    */
    
    //System.out.println(SysTime("yyyy年MM月"));
    //System.out.println(SysTime("yyyyMM"));
    //System.out.println(ConvertSpaceTD(""));
    //System.out.println(ConvertTD(""));
    
		/* process the stat data Start 
		Statement stmt1 = conn.createStatement(); 
		String sTableName = find_Type;
		String sUserName = findName;
		StringBuffer sBuffer = new StringBuffer();

		//Step 1 clear Table userState
		sBuffer.append("delete * from userStat;");

		//Step 2 read username from User_P and write inputnum in it
		sBuffer.append("select User_P.loginname,").append(sTableName).append(".createby,count(").append(sTableName).append(".createby)")
			.append(" from ").append(sTableName).append("")
			.append(" right join")
			.append(" User_P")
			.append(" on User_P.loginname=").append(sTableName).append(".createby")
			.append(" where 1=1");
		if (find_Name.compareTo("")!=0){
			sBuffer.append(" and ").append(sTableName).append(".createby='").append(sTableName).append("'");
		}
		if (find_DateStart.compareTo("")!=0){
			sBuffer.append(" and createdate<='").append(find_DateStart).append(" 00:00:00'");
		}
		if (find_DateStart.compareTo("")!=0){
			sBuffer.append(" and createdate>='").append(find_DateEnd).append(" 23:59:59'");
		}
		sBuffer.append(" group by ").append(sTableName).append(".createby")
			.append(";");


		//Step 3 read updatenum
		sBuffer.append("select count(updateby) from ").append(sTableName).append("")
			.append(" where ").append(sTableName).append(".updateby=''")
			.append(" and updatedate<='").append(find_DateStart).append(" 00:00:00'")
			.append(" and updatedate>='").append(find_DateEnd).append(" 23:59:59'")
			.append(";");

		//Step 4 update the userStat.updatenum value
		sBuffer.append("update userStat set updatenum='3' where updateby='").append(sTableName).append("'")
			.append(";");

		sBuffer.toString();

		 process the stat data End */

/*    
    try{
      System.out.println(SysDate());
       System.out.println(StrToDateTimeFormat("2003-08-21 18:28:47", "yyyy-MM-"));
    }catch(Exception e){
       
    }
    String s[] = SplitStr("asd,asd,we,sd",",");
    for (int curLayNum=0;curLayNum<s.length;curLayNum++){
      System.out.println(s[curLayNum]);
    }
    System.out.println(JoinStr(s,","));

    System.out.println(ReturnSysTime("yyyy-MM-dd"));
    //System.out.println(CoverDate(ReturnSysTime("yyyy-MM-dd HH:mm:ss"),"yyyy-MM-dd"));
    try {
      System.out.println(StrToTimestamp("2003-08-21 18:28:47", "yyyy-MM"));
      System.out.println(StrToDateTimeFormat("2003-08-21 18:28:47", "yyyy-MM"));
    }
    catch (ParseException ex) {
    }

    try {
      System.out.println(StrToTimestamp("2003-08-26", "yyyy-MM-dd"));
    }
    catch (ParseException ex) {
      System.out.println("StrToTimestamp error.");
    }*/
	  
	  System.out.println("finish!");
  }

/*
<script language=JavaScript>

  var today = new Date();
  var strDate = (today.getFullYear() + "年" +
(today.getMonth() + 1) + "月" + today.getDate() + "日 ");
  var n_day = today.getDay();
  switch (n_day)
  {
  case 0:{
  strDate = strDate + "星期日"
  }break;
  case 1:{
  strDate = strDate + "星期一"
  }break;
  case 2:{
  strDate = strDate + "星期二"
  }break;
  case 3:{
  strDate = strDate + "星期三"
  }break;
  case 4:{
  strDate = strDate + "星期四"
  }break;
  case 5:{
  strDate = strDate + "星期五"
  }break;
  case 6:{
  strDate = strDate + "星期六"
  }break;
  case 7:{
  strDate = strDate + "星期日"
  }break;
  }
  document.write(strDate);

</script>
*/

	public String replaceLast(String string, String toReplace, String replacement) {
		int pos = string.lastIndexOf(toReplace);
		if (pos > -1) {
			return string.substring(0, pos) + replacement + string.substring(pos + toReplace.length(), string.length());
		} else {
			return string;
		} 
	} 
	
	public static String getROOTPath(){
		UtilFuns uf = new UtilFuns();
		return uf.getClass().getResource("/").getPath().replace("/WEB-INF/classes/", "/").substring(1);
	}
	public String getClassRootPath(){
		return this.getClass().getResource("/").getPath();
	}
}