mysql 时间字段的存储与处理记录

SQL

  `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,

POJO


    private Timestamp createTime;

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

Service

        final Timestamp time = new Timestamp(System.currentTimeMillis());
        Foo foo = new Foo ();
        foo.setCreateTime(time);

 

你可能感兴趣的:(java,web)