首页>代码>java servlet开发企业网站,支持角色权限管理,文章增删改查>/enterprice/src/edu/nuc/projdemo/common/IPTimeStamp.java
package edu.nuc.projdemo.common;
import java.text.SimpleDateFormat ;
import java.util.Date ;
import java.util.Random ;
public class IPTimeStamp {
	private SimpleDateFormat sdf = null ;
	private String ip = null ;
	public IPTimeStamp(){
	}
	public IPTimeStamp(String ip){
		this.ip = ip ;
	}
	public String getIPTimeRand(){
		StringBuffer buf = new StringBuffer() ;
		if(this.ip != null){
			String s[] = this.ip.split("\\.") ;
			for(int i=0;i<s.length;i++){
				buf.append(this.addZero(s[i],3)) ;
			}
		}
		buf.append(this.getTimeStamp()) ;
		Random r = new Random() ;
		for(int i=0;i<3;i++){
			buf.append(r.nextInt(10)) ;
		}
		return buf.toString() ;
	}
	/*public String getDate(){
		this.sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS") ;
		return this.sdf.format(new Date()) ;
	}*/
	public String getTimeStamp(){
		this.sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS") ;
		return this.sdf.format(new Date()) ;
	}
	private String addZero(String str,int len){
		StringBuffer s = new StringBuffer() ;
		s.append(str) ;
		while(s.length() < len){
			s.insert(0,"0") ;
		}
		return s.toString() ;
	}
	
}
最近下载更多
求学的熊猫  LV11 2024年9月9日
2036495585  LV9 2023年9月26日
2063066273  LV2 2023年6月14日
xiaoying0820  LV1 2023年3月24日
liu2022  LV14 2022年7月31日
wanggongzi  LV1 2022年5月27日
www-chrome  LV6 2022年5月5日
zzz112  LV1 2022年4月21日
微信网友_5910834400677888  LV1 2022年4月10日
土豆侠  LV1 2022年3月2日
最近浏览更多
微信网友_7290996505972736  LV4 2024年12月11日
求学的熊猫  LV11 2024年9月9日
ma406805131  LV19 2024年6月15日
孙纪龙啊  LV10 2024年4月20日
微信网友_6446523832586240  LV1 2024年2月29日
asddwh  LV13 2023年12月25日
颜菜菜  LV2 2023年12月19日
15234568145  LV1 2023年12月5日
bubian 2023年11月12日
暂无贡献等级
jiemomo  LV12 2023年10月19日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友