package com.project.beautycenter.model; import javax.persistence.*; import java.text.SimpleDateFormat; import java.time.Instant; import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; @Entity @Table(name = "termini", schema = "project") public class Termini { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "termin_id", nullable = false) private Integer id; @Column(name = "pocetok", nullable = false) private Instant pocetok; @Column(name = "vremetraenje") private Integer vremetraenje; @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "user_id_vraboten", nullable = false) private Vraboteni vraboteni; @OneToMany(mappedBy = "termini") private Set rezervacijas = new LinkedHashSet<>(); public Termini(Instant pocetok, Integer vremetraenje, Vraboteni vraboten) { this.pocetok = pocetok; this.vremetraenje = vremetraenje; this.vraboteni = vraboten; } public Termini() { } public Instant pocetokFormatted2() { String stringPocetok = this.pocetok.toString(); String formatted = stringPocetok.substring(0, stringPocetok.length() - 1).concat("-02:00"); return Instant.parse(formatted); } public Set getRezervacijas() { return rezervacijas; } public void setRezervacijas(Set rezervacijas) { this.rezervacijas = rezervacijas; } public Vraboteni getVraboteni() { return vraboteni; } public void setVraboteni(Vraboteni vraboteni) { this.vraboteni = vraboteni; } public Integer getVremetraenje() { return vremetraenje; } public void setVremetraenje(Integer vremetraenje) { this.vremetraenje = vremetraenje; } public Instant getPocetok() { return pocetok; } public void setPocetok(Instant pocetok) { this.pocetok = pocetok; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String format() { Date myDate = Date.from(pocetok); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); String formattedDate = formatter.format(myDate); return formattedDate; } }