MyEclipse 中自定义日期格式
2024-08-28 18:50:45
从数据库中读出Data数据:
而想实现的是这样:
解决办法:
1. 在这个类里添加自定义的变量birthf:
public abstract class AbstractUsers implements java.io.Serializable {
…… ;
private String birthf;
}
2. 在各个构造函数中添加:
public AbstractUsers(…… , String birthf) {
…… ;
this.birthf = birthf;
}
3. 生成get,set函数,再在get函数里添加代码:
public String getBirthf() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd ");
Date date = (Date) this.getBirth();
birthf = sdf.format(date);
return birthf;
}
4. 在Users类里各构造函数里添加:
public class Users extends AbstractUsers implements java.io.Serializable {
public Users(……, String birthf) {
super(……,birthf);
}
}
5. 在.jsp中添加:
<li><span>出生日期:</span><%=user.getBirthf() %></li>
最新文章
- Git入门资料汇总
- web前端性能优化指南(转)
- Design3:使用HierarchyID构建数据的分层结构
- PyQt4自定义事件
- Dedecms include\dialog\select_soft_post.php Upload Any Files To The Specified Directory Via Variable Not Initial Flaw Bypass Extension Defence
- hdu 4345 Permutation 记忆化搜索
- linux ps top 命令 VSZ,RSS,TTY,STAT, VIRT,RES,SHR,DATA的含义【转】
- 模板方法模式(Template Method)
- POJ 2455 Secret Milking Machine (二分+无向图最大流)
- 布局重用 include merge ViewStub
- Google推出iOS功能性UI测试框架EarlGrey
- poj 3613 floyd + 快速幂
- 自学python Day01
- 输入docker ps 报错信息处理Get http:///var/run/docker.sock/v1.19/containers/json: dial unix /var/run/docker.sock: permission denied.
- Go 语言数据类型
- 在Unity3D里使用WinForm
- effective java——30使用enum
- zabbix 监控 redis
- Windows 操作系统与内核版本号
- Django之Models进阶操作(字段属性)