程序员的量化交易之路(17)--Cointrader之Temporal实体(5)

转载需要注明:http://blog.csdn.net/minimicallhttp://cloudtrader.top/

这一小节说明一个时间实体Temporal实体,它的代码很简单。

package org.cryptocoinpartners.schema;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import org.hibernate.annotations.Type;
import org.joda.time.Instant;

/**
 * @author Tim Olson
 */
//这个标注说明这个类也是一个基类,不会在数据库中创建表
@MappedSuperclass
public class Temporal extends EntityBase {

    public Temporal(Instant time) {
        super();
        this.time = time;
        this.dateTime = time.toDate();
        this.timestamp = time.getMillis();
    }

    /** For Events, this is the time the Event itself occured, not the time we received the Event.  It should be remote
     * server time if available, and local time if the object was created locally */
/@/Type注解用于说明类型
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentInstantAsMillisLong")
    @Basic(optional = false)
    public Instant getTime() {
        return time;
    }
//这个注解用于说明该字段不会存储到数据库中
    @Transient
    public Date getDateTime() {
        return dateTime;
    }

    @Transient
    public long getTimestamp() {
        return timestamp;
    }

    // JPA
    protected Temporal() {
    }

    protected void setTime(Instant time) {
        this.time = time;
        this.dateTime = time.toDate();
        this.timestamp = time.getMillis();
    }

    protected Instant time;//时间
    private long timestamp;//时间截
    private Date dateTime;//日期

}

需要说明的是,这个类

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值