类 StrHelper

java.lang.Object
com.sh.javax.util.StrHelper

public class StrHelper extends Object
一些字符串处理的功能

Company:首亨软件(重庆)有限公司

  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static String
    concat(String str1, String str2, char concatenator)
    将两个字符串通过一个连接符连接起来
    static boolean
    判断str字符串是否是in的子串
    static boolean
    getBoolean(String value, boolean defaultValue)
    将字符串转换成boolean值,如果字符串不是"true/false",则返回默认的boolean值
    static String
    将yyyy-MM-dd格式的字符串转化成yyyyMMdd
    static double
    getDouble(String value, double defaultValue)
    将字符串的值转化成double数值,如果出错,返回默认的值
    static float
    getFloat(String value, float defaultValue)
    将字符串转化成float数值,如果出错,返回默认值
    static int
    getInt(String value, int defaultValue)
    将字符串值转换成int,如果出错,返回默认值
    static boolean
    isEmpty(String value)
    判断某一个字符串是否为空或者长度为0
    static boolean
    判断字符串是否为null或空格串
    static boolean
    判断字符串是否不为null或空格串
    static String
    replace(String original, String find, String substitute)
    将一个字符串中某些字符替换成其它值
    static String[]
    toArray(String source, String delimiter)
    将一个字符串转化成字符串数组
    static String
    trim(String str)
    去掉字符串中所有的空格,包括字符串前后以及字符串中间的空格,如果是null,返回的是""
    static String
    trim(String str, boolean trimSpaces, boolean trimNonAlpha)
    去掉字符串中的空格或者非数字和字母的字符,如果是null,返回的是""
    static String
    把带时间的时间字符串转化为仅为年月日的,格式必须是 XXXX hh:mm
    static String
    把非标准时间格式的字符串转化为标准格式的

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • StrHelper

      public StrHelper()
  • 方法详细资料

    • containsString

      public static boolean containsString(String in, String str)
      判断str字符串是否是in的子串
      参数:
      in - String 主字符串
      str - String 需要测试的字符串
      返回:
      boolean true是in的子串;false不是in的子串
    • concat

      public static String concat(String str1, String str2, char concatenator)
      将两个字符串通过一个连接符连接起来
      参数:
      str1 - String 字符串1
      str2 - String 字符串2
      concatenator - char 连接字符
      返回:
      String 连接起来的新字符串
    • trim

      public static String trim(String str)
      去掉字符串中所有的空格,包括字符串前后以及字符串中间的空格,如果是null,返回的是""
      参数:
      str - String 需要去掉空格的字符串
      返回:
      String 去掉空格后的新的字符串
    • trim

      public static String trim(String str, boolean trimSpaces, boolean trimNonAlpha)
      去掉字符串中的空格或者非数字和字母的字符,如果是null,返回的是""
      参数:
      str - String 需要处理的字符串
      trimSpaces - boolean true去掉空格,false不去掉空格
      trimNonAlpha - boolean true去掉字母和数字以外的字符,false不去掉
      返回:
      String 去掉了所有空格或者非字母数字的新的字符串
    • getBoolean

      public static boolean getBoolean(String value, boolean defaultValue)
      将字符串转换成boolean值,如果字符串不是"true/false",则返回默认的boolean值
      参数:
      value - String 字符串
      defaultValue - boolean 默认的布尔值
      返回:
      boolean 转换后的布尔值
    • getInt

      public static int getInt(String value, int defaultValue)
      将字符串值转换成int,如果出错,返回默认值
      参数:
      value - String 字符串
      defaultValue - int 默认值
      返回:
      int 转化后的数值
    • getFloat

      public static float getFloat(String value, float defaultValue)
      将字符串转化成float数值,如果出错,返回默认值
      参数:
      value - String 字符串
      defaultValue - float 默认的float数值
      返回:
      float 转化后的float数值
    • getDouble

      public static double getDouble(String value, double defaultValue)
      将字符串的值转化成double数值,如果出错,返回默认的值
      参数:
      value - String 字符串
      defaultValue - double 默认的double数值
      返回:
      double 转化成的double值
    • toArray

      public static String[] toArray(String source, String delimiter)
      将一个字符串转化成字符串数组
      参数:
      source - String 字符串
      delimiter - String 字符串中的分隔符
      返回:
      String[] 返回的字符串数组
    • isNotEmptyStr

      public static boolean isNotEmptyStr(String str)
      判断字符串是否不为null或空格串
      参数:
      str - 被判断的字符
      返回:
      true表示“不为”
    • isEmptyStr

      public static boolean isEmptyStr(String str)
      判断字符串是否为null或空格串
      参数:
      str - 被判断的字符
      返回:
      true表示“为”
    • isEmpty

      public static boolean isEmpty(String value)
      判断某一个字符串是否为空或者长度为0
      参数:
      value - String 字符串
      返回:
      boolean true字符串为空,false字符串不为空
    • replace

      public static String replace(String original, String find, String substitute)
      将一个字符串中某些字符替换成其它值
      参数:
      original - String 原始字符串
      find - String 需要替换的字符串
      substitute - String 替换值
      返回:
      String 替换后的新的字符串
    • valueOfFullformat

      public static String valueOfFullformat(String time)
      把非标准时间格式的字符串转化为标准格式的
      参数:
      time - String 待转化的字符串
      返回:
      String 转化后的字符串
    • valueOfDateFormat

      public static String valueOfDateFormat(String time)
      把带时间的时间字符串转化为仅为年月日的,格式必须是 XXXX hh:mm
      参数:
      time - String 带事件的字符串
      返回:
      String 不带时间的字符串
    • getDateStr

      public static String getDateStr(String date)
      将yyyy-MM-dd格式的字符串转化成yyyyMMdd
      参数:
      date - String yyyy-MM-dd格式的字符串
      返回:
      String yyyyMMdd格式的字符串