简单的聊天程序
源代码在线查看: message.java
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Message implements Serializable{
protected String msg;
protected String time;
protected String sysMsg;
public Message(String sys,String msg)
{
this.sysMsg = sys;
this.msg = msg;
this.time = this.getTime();
}
//记录时间
private String getTime()
{
SimpleDateFormat df = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
String s = df.format(new Date());
return s+"\n";
}
public String toString()
{
return this.time+this.msg+"\n";
}
}