遍历List内容截取字符串

 1 /**
 2      * 限定指数长度为两位
 3      * @return
 4      */
 5     public List<BJtzsZoneComeAndCross> subStringJtzsIndex(List<BJtzsZoneComeAndCross> list){
 6         //list不为空
 7         String index = "";
 8         String Jtzs = "";
 9         if(list != null && list.size() != 0){
10             for (int i = 0; i<list.size();i++){
11                 index = list.get(i).getJtzs();
12                 if (index.length() > 4){
13                     Jtzs = index.substring(0,4);
14                 }else{
            Jtzs = Index;
           }
15 list.get(i).setJtzs(Jtzs); 16 } 17 } 18 return list; 19 }

 

posted @ 2018-11-02 12:10  闻长歌而知雅意  阅读(1931)  评论(0编辑  收藏  举报