SmartUpload使用和簡介

來源:互聯網
上載者:User

 

 

 

用以下代碼組建檔案名即可

 1 package info.haowei.util; 2  3 import java.text.SimpleDateFormat; 4 import java.util.Date; 5 import java.util.Random; 6  7 public class IPTimeStamp { 8  9     10     private SimpleDateFormat sdf = null;11     private String ip = null;12     13     14     public IPTimeStamp(String ip) {15         super();16     17         this.ip = ip;18     }19 20 21     public IPTimeStamp() {22         super();23     }24     25     26     public String getIPTimeRand(){27         StringBuffer buf = new StringBuffer();28         if(this.ip != null){29             String s[] = this.ip.split("\\.");//根據ip以點分割將IP中的數字提取30             for(int i = 0 ; i < s.length; i++){31                 buf.append(this.addZero(s[i], 3));//不夠三位元的補零32             }33         }34         buf.append(this.getTimeStamp());35         Random r = new Random();//再在結尾加上三個隨機數36         for(int i = 0 ; i < 3 ; i++ ){37             buf.append(r.nextInt(10));38         }39         return buf.toString();40     }41     42     private String addZero(String str, int len){43         44         StringBuffer s = new StringBuffer();45         s.append(str);46         while(s.length()<len){47             s.insert(0, 0);48         }49         50         return s.toString();51     }52     53     54     private String getTimeStamp(){//擷取時間戳記55         this.sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");56         return this.sdf.format(new Date());57     }58     59     public String getDate(){60         this.sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");61         return this.sdf.format(new Date());62     }63 }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.