Commit f14126fa by Patryk Czarnik

TimeResource - więcej metod

parent 0235a23a
package rest;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
@Path("/time")
@Path("/dt")
@Produces("text/plain;charset=UTF-8")
public class TimeResource {
// ta metoda obsługuje adres .../dt
@GET
public String getDateTime() {
return LocalDateTime.now().toString();
public LocalDateTime odczytajDataICzas() {
return LocalDateTime.now();
}
// ta metoda obsługuje adres .../dt/date
@GET
@Path("/second")
public int getSecond() {
return LocalDateTime.now().getSecond();
@Path("/date")
public LocalDate odczytajDate() {
return LocalDate.now();
}
// ta metoda obsługuje adres .../dt/date/year
@GET
@Path("/date/year")
public int odczytajRok() {
return LocalDate.now().getYear();
}
// ta metoda obsługuje adres .../dt/time
@GET
@Path("/time")
public LocalTime odczytajCzas() {
return LocalTime.now();
}
// ta metoda obsługuje adres .../dt/time/second
@GET
@Path("/time/second")
public int odczytajSekunde() {
return LocalTime.now().getSecond();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment