<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)  編輯  收藏

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


    網站導航:
     
    主站蜘蛛池模板: 免费一级毛片不卡不收费| 久久久精品免费国产四虎| 国拍在线精品视频免费观看| 日韩亚洲一区二区三区| 久久性生大片免费观看性| 久久久久亚洲av成人无码电影 | 国产片免费在线观看| 亚洲1234区乱码| 国产一精品一AV一免费孕妇| 亚洲av无码一区二区三区观看| 全免费毛片在线播放| 亚洲国产精品免费观看| 女人被免费视频网站| 亚洲精品无码日韩国产不卡av| 女人张开腿等男人桶免费视频| 亚洲欧洲AV无码专区| 国产又大又粗又硬又长免费 | 亚洲婷婷天堂在线综合| 一个人免费观看在线视频www| 亚洲依依成人亚洲社区| 免费看美女被靠到爽| 亚洲成av人无码亚洲成av人| 免费观看国产精品| 你懂的网址免费国产| 亚洲国产美国国产综合一区二区| 最近免费中文字幕大全免费版视频| 亚洲日本在线观看网址| 国内一级一级毛片a免费| 理论片在线观看免费| 亚洲欧洲自拍拍偷午夜色无码| 最近2019中文字幕免费直播| 亚洲av永久无码精品三区在线4 | 老子影院午夜伦不卡亚洲| 亚洲成A∨人片天堂网无码| 爱丫爱丫影院在线观看免费| 亚洲午夜久久久久久尤物| 又大又黄又粗又爽的免费视频| 免费无码又爽又刺激一高潮| 亚洲日本久久一区二区va| 亚洲国产一区明星换脸| 91精品视频在线免费观看|