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>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章