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

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

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

    java Source

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      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    分割好的字符串數組
     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 閱讀(1370) 評論(0)  編輯  收藏

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


    網站導航:
     
    主站蜘蛛池模板: 亚洲综合亚洲国产尤物| 亚洲美女视频网址| 日韩精品无码一区二区三区免费| 亚洲欧洲另类春色校园小说| 日本牲交大片免费观看| 91成人免费福利网站在线| 亚洲专区中文字幕| 中文字幕亚洲一区二区三区| 最新黄色免费网站| 污视频网站免费观看| 久久亚洲精品无码aⅴ大香| 国产成人啪精品视频免费网| 桃子视频在线观看高清免费视频 | 亚洲精品tv久久久久久久久| 成人免费视频69| CAOPORN国产精品免费视频| 亚洲一区二区三区高清不卡 | 女人让男人免费桶爽30分钟| 成在线人视频免费视频| 2017亚洲男人天堂一| 亚洲成a人片在线观看日本| 国产精品久久香蕉免费播放| 热re99久久6国产精品免费| 午夜在线免费视频| 亚洲六月丁香婷婷综合| 亚洲∧v久久久无码精品| 免费在线观看毛片| 最近2019中文字幕mv免费看| 无码av免费网站| 99re8这里有精品热视频免费| 亚洲Av无码国产一区二区| 亚洲手机中文字幕| 亚洲国产成人一区二区精品区| 男人的天堂亚洲一区二区三区| 国产成人AV片无码免费| 成人久久久观看免费毛片| 久久无码av亚洲精品色午夜| 亚洲喷奶水中文字幕电影| 亚洲国产人成在线观看69网站 | 亚洲jizzjizz在线播放久| 亚洲国产精品婷婷久久|