apache.commons.lang3_DateFormatUtils,RandomStringUtils

<pre name="code" class="java">System.out.println(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
//output 2015-05-04 18:50:54
System.out.println(DateFormatUtils.format(new Date(), "yyyy-MM-dd hh:mm:ss"));
//output 2015-05-04 06:50:22
		
System.out.println(DateUtils.addDays(new Date(), 1));//增加天数,时间。。等
System.out.println(DateUtils.isSameDay(new Date(), new Date()));//是否相同日期
System.out.println(DateUtils.parseDate("2015-05-04", "yyyy-MM-dd"));//str to Date
System.out.println(RandomStringUtils.randomNumeric(6));//生成随机六位数字   数字参数可以更改
System.out.println(RandomStringUtils.randomAlphabetic(6));//生成随机六位字母
System.out.println(RandomStringUtils.randomAlphanumeric(6));//生成随机六位字母数字组合
System.out.println(RandomStringUtils.random(6, true, true));//六位 第一个boolean 是否包含字母,第二个是否包含数字
System.out.println(RandomStringUtils.random(6, "abcdefghigkqqqiiiiqq"));//生成六位随机,按给出的字母中取得

</pre>

posted @ 2015-05-05 11:50  liubo6  阅读(313)  评论(0编辑  收藏  举报