public class RandomUtil extends Object
随机工具
该工具主要生成各种类型的随机字符串以便适应于各种场景。该工具的主要功能如下:Constructor and Description |
---|
RandomUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
chinese()
随机生成一个常见的汉字
|
static String |
chinese(int len)
生成指定长度的汉字
|
static String |
fromNow()
根据当前时间生成形如yyyyMMddhhmmss的字符串
|
static String |
fromNow(String prefix)
根据当前时间生成形如 前缀+yyyyMMddhhmmss的字符串
|
static String |
fromNowWithNumber()
根据当前时间生成形如yyyyMMddhhmmss100的字符串
|
public static final String chinese() throws UnsupportedEncodingException
UnsupportedEncodingException
- 系统不支持GBK编码public static final String chinese(int len) throws UnsupportedEncodingException
len
- 汉字长度UnsupportedEncodingException
- 系统不支持GBK编码public static final String fromNow()
public static final String fromNow(String prefix)
prefix
- 增加的前缀public static final String fromNowWithNumber()
根据当前时间生成形如yyyyMMddhhmmss100的字符串
其中yyyyMMddhhmmss部分为根据当前时间格式化生成,数字部分时100-999之间的随机数Copyright © 2021. All rights reserved.