<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    java Source

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      14 Posts :: 24 Stories :: 8 Comments :: 0 Trackbacks
      1/*
      2 * StringUtils.java
      3 * Copyright (C) 2007-3-19  <JustinLei@gmail.com>
      4 *
      5 *        This program is free software; you can redistribute it and/or modify
      6 *        it under the terms of the GNU General Public License as published by
      7 *      the Free Software Foundation; either version 2 of the License, or
      8 *     (at your option) any later version.
      9 *
     10 *       This program is distributed in the hope that it will be useful,
     11 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 *        GNU General Public License for more details.
     14 *
     15 */

     16package org.lambdasoft.utils;
     17
     18import java.text.SimpleDateFormat;
     19import java.util.ArrayList;
     20import java.util.Date;
     21import java.util.List;
     22import java.util.StringTokenizer;
     23
     24import org.apache.commons.logging.Log;
     25import org.apache.commons.logging.LogFactory;
     26
     27/**
     28 * 字符串處理工具
     29 * 
     30 * @author TangLei <justinlei@gmail.com>
     31 * @date 2008-11-22
     32 */

     33public class StringUtils {
     34    private final static Log log = LogFactory.getLog(StringUtils.class);
     35    private StringUtils(){}
     36    
     37    /**
     38     * 判斷字符串是否為空
     39     * 
     40     * @param str    需要判斷的字符串
     41     * @return booleanValue 返回是否為空
     42     */

     43    public final static boolean isEmpty(String str) {
     44        if(str == null)
     45            return true;
     46        str = str.trim();
     47        if(str.length() == 0)
     48            return true;
     49        return false;
     50    }

     51    
     52    /**
     53     * 判斷字符串是否為空
     54     * 
     55     * @param str    需要判斷的字符串
     56     * @return    booleanValue 返回是否為空
     57     */

     58    public final static boolean isNotEmpty(String str) {
     59        return ! isEmpty(str);
     60    }

     61    
     62    public final static long getLength(String str) {
     63        if(isEmpty(str))
     64            return 0;
     65        return str.trim().length();
     66    }

     67    
     68    /**
     69     * 獲取分割的字符串
     70     * 
     71     * @param str    需要分割的字符串
     72     * @param segment    分割字符串
     73     * @return    segments    分割好的字符串數(shù)組
     74     */

     75    public final static String[] getStringSegment(String str,String segment) {
     76        if(str == null || str.trim().length() == 0)
     77            return null;
     78        if(segment == null || segment.length() == 0)
     79            return null;
     80        StringTokenizer stringTokenizer = new StringTokenizer(str,segment);
     81        List<String> segs = new ArrayList<String>();
     82        while(stringTokenizer.hasMoreTokens()) {
     83            String _token = stringTokenizer.nextToken();
     84            segs.add(_token);
     85            if(log.isDebugEnabled()) {
     86                log.debug("StringTokenizer.nextToken : " + _token);
     87            }

     88        }

     89        String[] returns = new String[segs.size()];
     90        for (int i = 0; i < segs.size(); i++{
     91            returns[i] = segs.get(i);
     92        }

     93        return returns;
     94    }

     95    
     96    /**
     97     * 時間格式化默認為(yyyy-MM-dd HH:mm:ss)
     98     * 
     99     * @param date
    100     * @param expression
    101     * @return
    102     */

    103    public static final String formatDate(Date date,String expression) {
    104        if(isEmpty(expression))
    105            expression = "yyyy-MM-dd HH:mm:ss";
    106        SimpleDateFormat sdf = new SimpleDateFormat(expression);
    107        return sdf.format(date);
    108    }

    109}

    110
    posted on 2009-12-18 14:28 JustinLei 閱讀(1367) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導航:
     
    主站蜘蛛池模板: 精品亚洲成a人在线观看| 亚洲色偷偷综合亚洲AV伊人蜜桃| 深夜福利在线免费观看| 女人18特级一级毛片免费视频| 亚洲AV无码一区二区三区在线| 亚洲成人免费电影| 亚洲jjzzjjzz在线观看| 国产精品免费观看| 亚洲国产熟亚洲女视频| 在线视频免费国产成人| 无码免费又爽又高潮喷水的视频| 久久亚洲国产精品123区| 色www永久免费网站| 亚洲色图在线观看| 国产乱子精品免费视观看片| 亚洲综合激情五月丁香六月| 国产一级大片免费看| 成全视成人免费观看在线看 | 无码国模国产在线观看免费| 另类图片亚洲校园小说区| 国产av无码专区亚洲国产精品| 在线观看黄片免费入口不卡| 亚洲国产天堂在线观看| 精品熟女少妇AV免费观看| 美女18一级毛片免费看| 亚洲精品tv久久久久久久久| 51精品视频免费国产专区| 亚洲精品无码久久久久牙蜜区| 波多野结衣免费视频观看 | 337p日本欧洲亚洲大胆精品555588| 99久久精品免费精品国产| 亚洲国产av玩弄放荡人妇| 亚洲综合另类小说色区| 香蕉97超级碰碰碰免费公| 九九综合VA免费看| 亚洲春黄在线观看| 亚洲高清成人一区二区三区| 99在线观看免费视频| 精品无码专区亚洲| 亚洲综合在线观看视频| www国产亚洲精品久久久 |