类 Utils
java.lang.Object
com.gdxsoft.easyweb.utils.Utils
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static String将数组拼接为字符串static Stringbyte2hex(byte[] b) 已过时。static Stringbytes2hex(byte[] b) 将byte数组转换为16进制字符串static String已过时。static booleanConverts a Object to a boolean
Utils.cvtBool(null) = false
Utils.cvtBool("true") = true
Utils.cvtBool("TRUE") = true
Utils.cvtBool("tRUe") = true
Utils.cvtBool("on") = true
Utils.cvtBool("yes") = true
Utils.cvtBool("是") = true
Utils.toBoolean("y") = true
Utils.toBoolean("t") = truestatic int将字符串转换为整数,并忽略错误static IntegercvtInteger(String v) 将字符串转换为整型,并忽略错误static String删除字符串中的内容static String生成编码的URLstatic StringfilterHtml(String str) 基本功能:过滤所有以"<"开头以">"结尾的标签static StringgetAlertScript(String s1) static Date根据字符串返回日期static Date根据字符返回日期static String获取GMT(0)时间表达式,用于 Last-Modified等static StringgetDateGMTString(Calendar calendar) 获取GMT(0)时间表达式,用于 Last-Modified等static StringgetDateGMTString(Date date) 获取GMT(0)时间表达式,用于 Last-Modified等static StringgetDateString(Timestamp t1, String dateformatString) 获取时间格式static StringgetDateString(Calendar calendar, String dateformatString) 获取指定格式的 日期字符串
格式例如 yyyy-MM-dd HH:mm:ssstatic StringgetDateString(Date date) 获取默认格式 日期 ,例如2011-04-02static StringgetDateString(Date date, String dateformatString) 获取指定格式的 日期字符串
格式例如 yyyy-MM-dd HH:mm:ssstatic StringgetDateTimeString(Date date) 获取默认格式 日期和时间 ,例如 2011-04-02 11:29:31static String返回时间的xml格式,yyyy-mm-ddTHH:MM:SSstatic int获取和当天的日期天数static int返回两个日期之间的天数static int计算显示的宽度static String转换为gbkstatic StringgetGuid()获取 UUIDstatic StringgetJavascript(String s1) static StringgetOptions(String valueList, String textList, String v1) 获取SELECT的OPTION列表static MListStrgetParameters(String sql, String tag) 获取字符串中的参数(含中文)
例如:{CALL PR_EWA_HOR_STR (@a, @CO_UNID, @姓名, @姓名.hash)}getParameters(String s1, String tagStart, String tagEnd) 获取被前后标记包围的内容,例如{12121}static String[]getSqlSplit(String sql, String tag) 分割字符串为数组static ObjectgetTimeDiffValue(Object oriValue, int timeDiffMinutes) 获取时间与时差计算后的结果static TimestampgetTimestamp(String s1, String lang, boolean isUKFormat) 获取sql的timestampstatic StringgetTimeString(Date date) 获取默认格式 时间 ,例如 11:29:31static String转换为utf8static byte[]转换 hex字符串为二进制static Stringmd5(byte[] bytes) 取bytes的md5摘要static String取str的md5摘要static StringrandomStr(int length) 利用随机数生成字符串static String基本功能:替换指定的标签static voidreplaceStringBuilder(StringBuilder source, String findString, String replaceString) 替换 StringBuilder 的字符串static Stringsha1(byte[] bytes) 取bytes的 sha1 摘要static String取str的 sha1 摘要static String[][]split2String(String s1, String splitString0, String splitString1) 分割双重数组static String[]splitString(String s1, String splitString) 分割字符串,内容中若保留分割符,则表示两次,如“,”分割的话,内容中保留则通过",,"表示static booleantestString(String sourceString, String regexString) 正则测试static StringtextToHtml(String text) 将纯文本转换为HTMLstatic StringtextToInputValue(String text) 将纯文本转换成input/textarea所需格式static StringtextToJscript(String text) 生成脚本可以使用的文字,替换回车,双引号和 ”\“符static StringURLEncoder.encode (UTF-8)编码static longtimeDiffDays(Date t1, Date t2) t1-t2的间隔天数static longtimeDiffHours(Date t1, Date t2) t1-t2的间隔小时数static longtimeDiffMinutes(Date t1, Date t2) t1-t2的间隔分钟数static longtimeDiffMSeconds(Date t1, Date t2) t1-t2的间隔毫秒static longtimeDiffSeconds(Date t1, Date t2) t1-t2的间隔秒数static StringtoJsonPair(String name, String value) 生成Json成对表达式static StringURLDecoder.decode (UTF-8) 解码
-
构造器详细资料
-
Utils
public Utils()
-
-
方法详细资料
-
getJavascript
-
getAlertScript
-
randomStr
利用随机数生成字符串- 参数:
length- 生成的长度- 返回:
- 随机数生成字符串
-
toJsonPair
生成Json成对表达式- 参数:
name- 名称value- 值- 返回:
- Json成对表达式
-
timeDiffHours
t1-t2的间隔小时数- 参数:
t1- 时间1t2- 时间2- 返回:
- t1-t2的间隔小时数
-
timeDiffDays
t1-t2的间隔天数- 参数:
t1- 时间1t2- 时间2- 返回:
- t1-t2的间隔天数
-
timeDiffMinutes
t1-t2的间隔分钟数- 参数:
t1- 时间1t2- 时间2- 返回:
- t1-t2的间隔分钟数
-
timeDiffSeconds
t1-t2的间隔秒数- 参数:
t1- 时间1t2- 时间2- 返回:
- t1-t2的间隔秒数
-
timeDiffMSeconds
t1-t2的间隔毫秒- 参数:
t1- 时间1t2- 时间2- 返回:
- t1-t2的间隔毫秒
-
split2String
分割双重数组- 参数:
s1- 字符串splitString0- 第一层数组分割符splitString1- 第二层数组分割符- 返回:
- 双重数组
-
splitString
分割字符串,内容中若保留分割符,则表示两次,如“,”分割的话,内容中保留则通过",,"表示- 参数:
s1- 字符splitString- 分割符- 返回:
- 数组
-
cvtBool
Converts a Object to a boolean
Utils.cvtBool(null) = false
Utils.cvtBool("true") = true
Utils.cvtBool("TRUE") = true
Utils.cvtBool("tRUe") = true
Utils.cvtBool("on") = true
Utils.cvtBool("yes") = true
Utils.cvtBool("是") = true
Utils.toBoolean("y") = true
Utils.toBoolean("t") = true- 参数:
object- the Object to check- 返回:
- boolean result
-
cvtInteger
将字符串转换为整型,并忽略错误- 参数:
v- 对象- 返回:
- 整型
-
cvtInt
将字符串转换为整数,并忽略错误- 参数:
v- 对象- 返回:
- 如果为null, 返回 0
-
arrayJoin
将数组拼接为字符串- 参数:
arr- 字符串数组joinString- 拼接字符串- 返回:
- 数组拼接为字符串
-
createEncryptString
已过时。同 sha1, sha1 摘要- 参数:
s1- 原始字符- 返回:
- sha1 摘要(HEX)
-
sha1
取bytes的 sha1 摘要- 参数:
bytes- 二进制数组- 返回:
- sha1 摘要(HEX)
-
sha1
取str的 sha1 摘要- 参数:
str- 字符串- 返回:
- sha1 摘要(HEX)
-
md5
取bytes的md5摘要- 参数:
bytes- 二进制数组- 返回:
- md5摘要(HEX)
-
md5
取str的md5摘要- 参数:
str- 字符串- 返回:
- md5摘要(HEX)
-
bytes2hex
将byte数组转换为16进制字符串- 参数:
b- byte数组- 返回:
- 16进制字符串
-
byte2hex
已过时。拼写错误,请用 bytes2hex 将byte数组转换为16进制字符串- 参数:
b- byte数组- 返回:
- 16进制字符串
-
hex2bytes
转换 hex字符串为二进制- 参数:
hexs- hex字符串- 返回:
- 二进制
-
getUtf8
转换为utf8- 参数:
s1- iso8859编码字符串- 返回:
- utf8字符串
-
getGbk
转换为gbk- 参数:
s1- iso8859编码字符串- 返回:
- gbk字符串
-
getParameters
获取被前后标记包围的内容,例如{12121}- 参数:
s1- 原始内容tagStart- 开始字符串tagEnd- 结束字符串- 返回:
- 参数数组
-
getParameters
获取字符串中的参数(含中文)
例如:{CALL PR_EWA_HOR_STR (@a, @CO_UNID, @姓名, @姓名.hash)}- 参数:
sql- 字符串tag- 参数前导字符例如 @- 返回:
- 参数表
-
testString
正则测试- 参数:
sourceString- 字符串regexString- 正则- 返回:
- 测试结果
-
getSqlSplit
分割字符串为数组- 参数:
sql- 字符串tag- 分割标记- 返回:
- 数组
-
textToInputValue
将纯文本转换成input/textarea所需格式- 参数:
text- 文本- 返回:
- input/textarea所需格式
-
textToHtml
将纯文本转换为HTML- 参数:
text-- 返回:
- HTML
-
textToJscript
生成脚本可以使用的文字,替换回车,双引号和 ”\“符- 参数:
text- 原始文字- 返回:
- 替换后的js文字
-
textToUrl
URLEncoder.encode (UTF-8)编码- 参数:
text- 明文- 返回:
- 编码后的字符串
-
urlToText
URLDecoder.decode (UTF-8) 解码- 参数:
urlEncoder- URLEncoder的字符串- 返回:
- 解码后的字符串
-
encodeUrl
生成编码的URL- 参数:
s- 字符串- 返回:
- 编码后的url
-
getTimeDiffValue
获取时间与时差计算后的结果- 参数:
oriValue-timeDiffMinutes-- 返回:
- 新时间(根据oriValue 的 class,创建 JAVA.SQL.TIMESTAMP/java.util.Date)
-
getDateString
获取时间格式- 参数:
t1- 时间dateformatString- 格式- 返回:
- 格式后的时间
-
getDateGMTString
获取GMT(0)时间表达式,用于 Last-Modified等- 参数:
date- 时间- 返回:
- GMT时间
-
getDateGMTString
获取GMT(0)时间表达式,用于 Last-Modified等- 参数:
t1- 时间- 返回:
- GMT时间
-
getDateGMTString
获取GMT(0)时间表达式,用于 Last-Modified等- 参数:
calendar- 时间- 返回:
- GMT时间
-
getDateXmlString
返回时间的xml格式,yyyy-mm-ddTHH:MM:SS- 参数:
t1- 时间- 返回:
- xml格式,yyyy-mm-ddTHH:MM:SS
-
getDateString
获取指定格式的 日期字符串
格式例如 yyyy-MM-dd HH:mm:ss- 参数:
calendar- 时间dateformatString- (yyyy-MM-dd HH:mm:ss)- 返回:
- 格式的 日期字符串
-
getDateString
获取指定格式的 日期字符串
格式例如 yyyy-MM-dd HH:mm:ss- 参数:
date- 时间dateformatString- (yyyy-MM-dd HH:mm:ss)- 返回:
- 格式的 日期字符串
-
getDateString
获取默认格式 日期 ,例如2011-04-02- 参数:
date- 时间- 返回:
- 默认格式 日期
-
getDateTimeString
获取默认格式 日期和时间 ,例如 2011-04-02 11:29:31- 参数:
date- 时间- 返回:
- 默认格式 日期和时间
-
getTimeString
获取默认格式 时间 ,例如 11:29:31- 参数:
date- 时间- 返回:
- 默认格式 时间
-
getGuid
获取 UUID- 返回:
- UUID字符串
-
getOptions
获取SELECT的OPTION列表- 参数:
valueList- Option 的 value列表,用”,“分割textList- Option 的 text列表,用”,“分割v1- 当前值- 返回:
- Options
-
getDays
获取和当天的日期天数- 参数:
date1-- 返回:
- 天数
-
getDays
返回两个日期之间的天数- 参数:
date1-date2-- 返回:
- 两个日期之间的天数
-
getDate
根据字符串返回日期- 参数:
dateString- yyyy-MM-dd,MM/dd/yyyy,8位数字- 返回:
- 日期
-
getDate
根据字符返回日期- 参数:
dateString- 日期字符串dateFormat- 日期格式- 返回:
- 日期
-
getTimestamp
获取sql的timestamp- 参数:
s1- 日期字符串lang- 语言isUKFormat- 当lang=enus时,是否为英式- 返回:
- sql的timestamp
-
getDisplayWidth
计算显示的宽度- 参数:
s1- 字符串- 返回:
- 显示的宽度
-
replaceStringBuilder
public static void replaceStringBuilder(StringBuilder source, String findString, String replaceString) 替换 StringBuilder 的字符串- 参数:
source- StringBuilder源findString- 需要替换的文字replaceString- 替换的内容
-
deleteStr
删除字符串中的内容- 参数:
source- 源find1- 开始查找的字符串find2- 后面查找的字符串- 返回:
- 删除字符串中的内容
-
filterHtml
基本功能:过滤所有以"<"开头以">"结尾的标签- 参数:
str- 字符串- 返回:
- String 过滤后的结果
-
replaceHtmlTag
public static String replaceHtmlTag(String str, String beforeTag, String tagAttrib, String startTag, String endTag) 基本功能:替换指定的标签- 参数:
str-beforeTag- 要替换的标签tagAttrib- 要替换的标签属性值startTag- 新标签开始标记endTag- 新标签结束标记- 返回:
- String @如:替换img标签的src属性值为[img]属性值[/img]
-