我的记事本项目之路(二)
来源:互联网 发布:ug三维制图软件 编辑:程序博客网 时间:2024/04/28 13:17
做好登陆界面之后,接下来就是记事本的主体了!首先,根据java面向对象的思想,记事本对象可以给它设置一个Note类,这样做的好处是:能够将Note()类封装起来,调用的时候只能通过get()和set()方法调用,大大的增加了安全性,Note.java代码如下:
package com.example.jishiben;
import java.io.Serializable;
public class Note implements Serializable {
private int id;
private String date;
private String type;
private String introduction = "";
public Note() {
}
public Note(int id, String date, String type, String introduction) {
super();
this.id = id;
this.date = date;
this.type = type;
this.introduction = introduction;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getIntroduction() {
return introduction;
}
public void setIntroduction(String introduction) {
this.introduction = introduction;
}
}
记事本的话,肯定还需要显示时间,这样才能根据事件的时间先后顺序进行排序,这里建一个时间工具类DateUtil.java,功能是获取系统的当前时间,并按照需要的格式进行格式化.代码如下:
package com.example.jishiben;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtil {
public static String formatDate(long time) {
Date date = new Date(time);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return sdf.format(date);
}
}
预知后事如何,请听下回分解.
- 我的记事本项目之路(二)
- 我的记事本项目之路(一)
- 我的记事本项目之路(三)
- 我的记事本项目之路(四)
- 我的记事本项目之路(五)
- 我的项目之路(二)
- 我的记事本之--管理记事
- Java小程序之我的记事本
- 我的项目重构之路二
- 我的记事本
- 我的记事本
- 我的记事本
- 我的记事本
- 我的记事本程序
- java-我的记事本
- 我的记事本
- 我的记事本之-SQLite数据库的使用
- 我的Java之路——一 记事本编写Java小程序
- 周边公交站台接口 查询附近的公交站台
- C字符串转JNI字符串
- 自定义配置文件读取
- iOS开发系列--音频播放、录音、视频播放、拍照、视频录制
- 安卓设置布局边框
- 我的记事本项目之路(二)
- 文本属性Attributes
- 机器学习(5)——决策树(下)算法实现
- oracle数据库ORA-00600:internalerrorcode,arguments:[keltnfy-ldmInit],[46],[1],[],[],[],[],[])
- pl-------------linux执行.pl文件
- Java并发编程 之 线程池核心ThreadPoolExecutor
- 【FastDev4Android框架开发】消息总线EventBus的基本使用(二十)
- MVC中的ViewData和ViewBag
- 新建android项目,找不到样式“textViewStyle”,无法生成R.java文件