fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.time.LocalTime;
  7. import java.sql.Time;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. // your code goes here
  15. var res = new Reservation("11:05", "18:05");
  16. System.out.println(res);
  17.  
  18. Time timeIn = Time.valueOf( "11:05:00" );
  19. Time timeOut = Time.valueOf( res.getCheckOutTime() );
  20. }
  21.  
  22. static class Reservation {
  23. LocalTime checkIn;
  24. LocalTime checkOut;
  25.  
  26. public Reservation(String in, String out) {
  27. this.checkIn = LocalTime.parse(in);
  28. this.checkOut = LocalTime.parse(out);
  29. }
  30.  
  31. public LocalTime getCheckInTime() {
  32. return checkIn;
  33. }
  34. public LocalTime getCheckOutTime() {
  35. return checkOut;
  36. }
  37.  
  38. public String toString() {
  39. return String.format("Reservation {checkIn: %s, checkOut: %s}", getCheckInTime(), getCheckOutTime());
  40. }
  41. }
  42.  
  43. }
Success #stdin #stdout 0.11s 53768KB
stdin
Standard input is empty
stdout
Reservation {checkIn: 11:05, checkOut: 18:05}