zoukankan      html  css  js  c++  java
  • MyEclipse 中自定义日期格式

    从数据库中读出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>

  • 相关阅读:
    18软工实践-第三次作业-结对项目1
    结对作业之代码规范
    ALPHA(7)
    ALPHA(6)
    ALPHA(五)
    404 Note Found 现场编程
    ALPHA(四)
    ALPHA冲刺(三)
    ALpha冲刺(二)
    ALPHA 冲刺(一)
  • 原文地址:https://www.cnblogs.com/lxt287994374/p/3451283.html
Copyright © 2011-2022 走看看