Package CN. mldn. lxh. util; 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 address! = NULL) {string s [] = This. IP. split ("\\. "); For (INT I = 0; I <S. length; I ++) {Buf. append (this. addzero (s [I], 3); // Add 0} Buf if there are not three digits. append (this. gettimestamp (); // obtain the time stamp random r = new random (); For (INT I = 0; I <3; I ++) {Buf. append (R. nextint (10); // Add a random number} return Buf. tostring ();} 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 ();} 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 ());}}