Commit f14126fa by Patryk Czarnik

TimeResource - więcej metod

parent 0235a23a
package rest; package rest;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import jakarta.ws.rs.GET; import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
@Path("/time") @Path("/dt")
@Produces("text/plain;charset=UTF-8")
public class TimeResource { public class TimeResource {
// ta metoda obsługuje adres .../dt
@GET @GET
public String getDateTime() { public LocalDateTime odczytajDataICzas() {
return LocalDateTime.now().toString(); return LocalDateTime.now();
} }
// ta metoda obsługuje adres .../dt/date
@GET @GET
@Path("/second") @Path("/date")
public int getSecond() { public LocalDate odczytajDate() {
return LocalDateTime.now().getSecond(); 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