1 48 49 package org.exolab.jms.message; 50 51 import java.io.Externalizable ; 52 import java.io.IOException ; 53 import java.io.ObjectInput ; 54 import java.io.ObjectOutput ; 55 import java.util.Date ; 56 57 63 public class Timestamp extends Date implements Externalizable { 64 65 static final long serialVersionUID = 1; 67 68 public Timestamp() { 69 super(); 70 } 71 72 public Timestamp(long datetime) { 74 super(datetime); 75 } 76 77 public void writeExternal(ObjectOutput out) throws IOException { 79 out.writeLong(serialVersionUID); 80 out.writeLong(getTime()); 81 } 82 83 public void readExternal(ObjectInput in) 85 throws IOException , ClassNotFoundException { 86 long version = in.readLong(); 87 long timestamp; 88 if (version == serialVersionUID) { 89 timestamp = in.readLong(); 90 setTime(timestamp); 91 } else { 92 throw new IOException ("Incorrect version enountered: " + 93 version + " This version = " + 94 serialVersionUID); 95 } 96 } 97 98 public long toLong() { 100 return getTime(); 101 } 102 103 public void setNow() { 105 setTime(System.currentTimeMillis()); 106 } 107 } 108 109 110 111 | Popular Tags |