Java tutorial
package netload.model; import org.springframework.format.annotation.DateTimeFormat; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import java.util.Date; /** * Copyright (C) 01/02/17 martijn * <p> * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * <p> * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p> * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ @Entity @Table(name = "Day") public class Day implements Comparable<Day> { @Id @Column(name = "id") private int id; @DateTimeFormat(pattern = "dd-MM-yyyy") @Column(name = "datum") private Date datum; @Column(name = "total") private double total; @Column(name = "up") private double up; @Column(name = "down") private double down; public Day(int id, Date datum, double total, double up, double down) { this.id = id; this.datum = datum; this.total = total; this.up = up; this.down = down; } public Day() { } public int getId() { return id; } public void setId(int id) { this.id = id; } public Date getDatum() { return datum; } public void setDatum(Date datum) { this.datum = datum; } public double getTotal() { return total; } public void setTotal(double total) { this.total = total; } public double getUp() { return up; } public void setUp(double up) { this.up = up; } public double getDown() { return down; } public void setDown(double down) { this.down = down; } @Override public int compareTo(Day day) { return getDatum().compareTo(day.getDatum()); } }