📄 log.java
字号:
package com.galaxyworkstation.model;
import java.text.DateFormat;
import java.util.Date;
/**
* 该类模拟了记录系统操作的日志,实现了Comparable接口
* @author 李奕
* @version 1.0
*/
public class Log implements Comparable<Log>{
private long ID;
private String action;
/**
* 默认构造函数
*/
public Log() {
this.ID = new Date().getTime();
action = "";
}
/**
* 构造函数
* @param action 一项操作的描述
*/
public Log(String action) {
this.ID = new Date().getTime();
this.action = action;
}
/**
* 得到一项操作的描述
* @return 操作的描述
*/
public String getAction() {
return action;
}
/**
* 设置一项操作的描述
* @param action 一项操作的描述
*/
public void setAction(String action) {
this.action = action;
}
/**
* 得到日志的ID
* @return 日志的ID
*/
public long getID() {
return ID;
}
/**
* 得到日志的时间的字符串形式
* @return 日志的时间的字符串形式
*/
public String getDateString(){
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.MEDIUM);
return dateFormat.format(new Date(ID));
}
/**
* 设置日志打印的格式
* @return 日志打印的格式
*/
public String toString() {
return getDateString() + "------" + action;
}
/**
* 实现Compareable接口中定义的方法
*/
public int compareTo(Log log){
return (this.ID < log.getID())?-1:1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -