1 | package com.project.beautycenter.model;
|
---|
2 |
|
---|
3 | import javax.persistence.*;
|
---|
4 | import java.text.SimpleDateFormat;
|
---|
5 | import java.time.Instant;
|
---|
6 | import java.util.Date;
|
---|
7 | import java.util.LinkedHashSet;
|
---|
8 | import java.util.Set;
|
---|
9 |
|
---|
10 | @Entity
|
---|
11 | @Table(name = "termini", schema = "project")
|
---|
12 | public class Termini {
|
---|
13 | @Id
|
---|
14 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
15 | @Column(name = "termin_id", nullable = false)
|
---|
16 | private Integer id;
|
---|
17 |
|
---|
18 | @Column(name = "pocetok", nullable = false)
|
---|
19 |
|
---|
20 | private Instant pocetok;
|
---|
21 |
|
---|
22 | @Column(name = "vremetraenje")
|
---|
23 | private Integer vremetraenje;
|
---|
24 |
|
---|
25 | @ManyToOne(fetch = FetchType.LAZY, optional = false)
|
---|
26 | @JoinColumn(name = "user_id_vraboten", nullable = false)
|
---|
27 | private Vraboteni vraboteni;
|
---|
28 |
|
---|
29 | @OneToMany(mappedBy = "termini")
|
---|
30 | private Set<Rezervacija> rezervacijas = new LinkedHashSet<>();
|
---|
31 |
|
---|
32 | public Termini(Instant pocetok, Integer vremetraenje, Vraboteni vraboten) {
|
---|
33 | this.pocetok = pocetok;
|
---|
34 | this.vremetraenje = vremetraenje;
|
---|
35 | this.vraboteni = vraboten;
|
---|
36 | }
|
---|
37 |
|
---|
38 | public Termini() {
|
---|
39 | }
|
---|
40 |
|
---|
41 | public Instant pocetokFormatted2() {
|
---|
42 | String stringPocetok = this.pocetok.toString();
|
---|
43 |
|
---|
44 | String formatted = stringPocetok.substring(0, stringPocetok.length() - 1).concat("-02:00");
|
---|
45 | return Instant.parse(formatted);
|
---|
46 |
|
---|
47 | }
|
---|
48 |
|
---|
49 | public Set<Rezervacija> getRezervacijas() {
|
---|
50 | return rezervacijas;
|
---|
51 | }
|
---|
52 |
|
---|
53 | public void setRezervacijas(Set<Rezervacija> rezervacijas) {
|
---|
54 | this.rezervacijas = rezervacijas;
|
---|
55 | }
|
---|
56 |
|
---|
57 | public Vraboteni getVraboteni() {
|
---|
58 | return vraboteni;
|
---|
59 | }
|
---|
60 |
|
---|
61 | public void setVraboteni(Vraboteni vraboteni) {
|
---|
62 | this.vraboteni = vraboteni;
|
---|
63 | }
|
---|
64 |
|
---|
65 | public Integer getVremetraenje() {
|
---|
66 | return vremetraenje;
|
---|
67 | }
|
---|
68 |
|
---|
69 | public void setVremetraenje(Integer vremetraenje) {
|
---|
70 | this.vremetraenje = vremetraenje;
|
---|
71 | }
|
---|
72 |
|
---|
73 | public Instant getPocetok() {
|
---|
74 | return pocetok;
|
---|
75 | }
|
---|
76 |
|
---|
77 | public void setPocetok(Instant pocetok) {
|
---|
78 | this.pocetok = pocetok;
|
---|
79 | }
|
---|
80 |
|
---|
81 | public Integer getId() {
|
---|
82 | return id;
|
---|
83 | }
|
---|
84 |
|
---|
85 | public void setId(Integer id) {
|
---|
86 | this.id = id;
|
---|
87 | }
|
---|
88 |
|
---|
89 | public String format() {
|
---|
90 | Date myDate = Date.from(pocetok);
|
---|
91 | SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
|
---|
92 | String formattedDate = formatter.format(myDate);
|
---|
93 | return formattedDate;
|
---|
94 | }
|
---|
95 |
|
---|
96 | } |
---|