List of usage examples for java.time LocalTime of
public static LocalTime of(int hour, int minute)
From source file:Main.java
public static void main(String[] argv) { LocalTime d = LocalTime.of(13, 51); System.out.println(d); }
From source file:Main.java
public static void main(String[] args) { LocalTime l = LocalTime.of(12, 23); System.out.println(l); }
From source file:Main.java
public static void main(String[] args) { int hours = 12; int minutes = 30; LocalTime classStart = LocalTime.of(hours, minutes); System.out.println(classStart); }
From source file:Main.java
public static void main(String[] args) { LocalTime currentTime = LocalTime.now(); // current time System.out.println(currentTime); LocalTime midday = LocalTime.of(12, 0); // 12:00 System.out.println(midday); // 12:00 LocalTime afterMidday = LocalTime.of(13, 30, 15); // 13:30:15 System.out.println(afterMidday); // 13:30:15 // 12345th second of day (03:25:45) LocalTime fromSecondsOfDay = LocalTime.ofSecondOfDay(12345); System.out.println(fromSecondsOfDay); // 03:25:45 }
From source file:Main.java
public static void main(String[] args) { // current/*from ww w . ja va 2s . c o m*/ LocalTime localTime1 = LocalTime.now(); System.out.println(localTime1); // 09:30 LocalTime localTime2 = LocalTime.of(9, 30); System.out.println(localTime2); // 09:30:50 LocalTime localTime3 = LocalTime.of(9, 30, 50); System.out.println(localTime3); // 09:30:50.000005678 LocalTime localTime4 = LocalTime.of(9, 30, 50, 5678); System.out.println(localTime4); }
From source file:Main.java
public static void main(String[] args) { LocalDate ld1 = LocalDate.of(2014, Month.JANUARY, 7); LocalDate ld2 = LocalDate.of(2014, Month.MAY, 18); LocalTime lt1 = LocalTime.of(7, 0); LocalTime lt2 = LocalTime.of(9, 30); long days = ld1.until(ld2, ChronoUnit.DAYS); System.out.println(days);//from w w w . j a v a 2 s . c o m long hours = lt1.until(lt2, ChronoUnit.HOURS); System.out.println(hours); long minutes = lt1.until(lt2, ChronoUnit.MINUTES); System.out.println(minutes); }
From source file:Main.java
public static void main(String[] args) { LocalDate ld1 = LocalDate.of(2014, Month.JANUARY, 7); LocalDate ld2 = LocalDate.of(2014, Month.MAY, 21); long days = ChronoUnit.DAYS.between(ld1, ld2); System.out.println(days);/* w w w .jav a2s. c om*/ LocalTime lt1 = LocalTime.of(6, 0); LocalTime lt2 = LocalTime.of(9, 30); long hours = ChronoUnit.HOURS.between(lt1, lt2); System.out.println(hours); long minutes = ChronoUnit.MINUTES.between(lt1, lt2); System.out.println(minutes); }
From source file:Main.java
public static void main(String[] args) { // the current date LocalDate currentDate = LocalDate.now(); // 2014-02-10 LocalDate tenthFeb2014 = LocalDate.of(2014, Month.FEBRUARY, 10); // months values start at 1 (2014-08-01) LocalDate firstAug2014 = LocalDate.of(2014, 8, 1); // the 65th day of 2010 (2010-03-06) LocalDate sixtyFifthDayOf2010 = LocalDate.ofYearDay(2010, 65); // times, e.g. 19:12:30.733 LocalTime currentTime = LocalTime.now(); // current time LocalTime midday = LocalTime.of(12, 0); // 12:00 LocalTime afterMidday = LocalTime.of(13, 30, 15); // 13:30:15 // 12345th second of day (03:25:45) LocalTime fromSecondsOfDay = LocalTime.ofSecondOfDay(12345); // dates with times, e.g. 2014-02-18T19:08:37.950 LocalDateTime currentDateTime = LocalDateTime.now(); // 2014-10-02 12:30 LocalDateTime secondAug2014 = LocalDateTime.of(2014, 10, 2, 12, 30); // 2014-12-24 12:00 LocalDateTime christmas2014 = LocalDateTime.of(2014, Month.DECEMBER, 24, 12, 0); // current (local) time in Los Angeles LocalTime currentTimeInLosAngeles = LocalTime.now(ZoneId.of("America/Los_Angeles")); // current time in UTC time zone LocalTime nowInUtc = LocalTime.now(Clock.systemUTC()); System.out.println("date/time creation: currentDate: " + currentDate); System.out.println("date/time creation: tenthFeb2014: " + tenthFeb2014); System.out.println("date/time creation: firstAug2014: " + firstAug2014); System.out.println("date/time creation: sixtyFifthDayOf2010: " + sixtyFifthDayOf2010); System.out.println("date/time creation: currentTime: " + currentTime); System.out.println("date/time creation: midday: " + midday); System.out.println("date/time creation: afterMidday: " + afterMidday); System.out.println("date/time creation: fromSecondsOfDay: " + fromSecondsOfDay); System.out.println("date/time creation: currentTimeInLosAngeles: " + currentTimeInLosAngeles); System.out.println("date/time creation: currentDateTime: " + currentDateTime); System.out.println("date/time creation: secondAug2014: " + secondAug2014); System.out.println("date/time creation: christmas2014: " + christmas2014); }
From source file:pruebas.PruebasReserva.java
public static void main(String[] args) { /*Usuario user = new Usuario("email@deprueba.com"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm"); LocalDateTime horaInicio = LocalDateTime.parse("01-06-2017 08:00", formatter); LocalDateTime horaFin = LocalDateTime.parse("01-06-2017 22:30", formatter); Horario horario = new Horario(horaInicio, horaFin, 10); //from www . j a v a 2 s . c o m GestorMesa gestor = new GestorMesa(0, "prueba1", null, null, null); for(int i = 0; i< 4; i++){ gestor.addMesa(new Mesa(i,4, horario)); } //Reservar 1 mesa comportamiento normal Mesa mesa = gestor.findMesa(0); System.out.println("El findMesa(0) da como resultado : "+ mesa.toString()); MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter("mesaId", "0"); request.getSession().setAttribute("usuario", user); System.out.println(request.getSession().getAttribute("usuario")); System.out.println("Antes de reservar: " + mesa.isDisponibleNow()); System.out.println(gestor.sentarEnMesa(request)); System.out.println(mesa.isDisponibleNow()); System.out.println(gestor.sentarEnMesa(request)); System.out.println(gestor.levantarDeMesa(request)); //System.out.println(gestor.sentarEnMesa(request)); ZonedDateTime horaReserva = LocalDateTime.of(2017,6,1, 12,0).atZone(ZoneId.systemDefault()); ZonedDateTime horaReserva2 = LocalDateTime.of(2017,6,1, 15,0).atZone(ZoneId.systemDefault()); //System.out.println("Current time: " + Long.toString(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli())); //System.out.println("Reservation time: " + Long.toString(horaReserva.toInstant().toEpochMilli())); //System.out.println("Start time: " + Long.toString(horaInicio.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli())); request.setParameter("hora", Long.toString(horaReserva.toInstant().toEpochMilli())); System.out.println(gestor.reservarMesa(request)); request.setParameter("hora", Long.toString(horaReserva2.toInstant().toEpochMilli())); System.out.println(gestor.reservarMesa(request)); System.out.println(mesa.isDisponibleAt(LocalDateTime.of(2017,6,1, 15,0))); System.out.println(gestor.levantarDeMesa(request)); System.out.println(mesa.isDisponibleAt(LocalDateTime.of(2017,6,1, 15,0))); System.out.println(gestor.reservarMesa(request)); LocalDate hoy = LocalDate.now(); LocalTime horaInicio = LocalTime.of(12, 30); LocalTime horaFin = LocalTime.of(23, 30); LocalDateTime defaultInicio = LocalDateTime.of(hoy, horaInicio); LocalDateTime defaultFin = LocalDateTime.of(hoy, horaFin); System.out.println("Inicio : " + defaultInicio + " y el Fin: " + defaultFin);*/ //Pruebas del Horario para mostrar las disponibles LocalDate hoy = LocalDate.now(); LocalTime horaInicio = LocalTime.of(12, 30); LocalTime horaFin = LocalTime.of(23, 30); LocalDateTime dateTimeInicio = LocalDateTime.of(hoy, horaInicio); LocalDateTime dateTimeFin = LocalDateTime.of(hoy, horaFin); /*Horario horario = new Horario(dateTimeInicio, dateTimeFin, 10); System.out.println("Antes: " + horario.getHorasLibres()); LocalTime horaReserva = LocalTime.of(20,0); LocalDateTime timeReserva = LocalDateTime.of(hoy, horaReserva); horario.reservarAt(timeReserva, 1); List lista = horario.getHorasLibres(); System.out.println("Despues: " + horario.getHorasLibres()); horario.eliminarReserva(1); System.out.println("Eliminada: " + horario.getHorasLibres()); horario.reservarAt(LocalDateTime.now(), 2); System.out.println("Despues: " + horario.getHorasLibres());*/ }
From source file:de.msg.repository.driver.TestRouteRepositoryDriver.java
@PostConstruct public void initRoutesList() { for (short i = 0; i < routeCount; i++) { String flightNumber = flightNumberList.get(i); String departure = departureList.get(i); String destination = destinationList.get(i); Route route = new Route(flightNumber, departure, destination); route.setId(new Long(i + 1)); route.addScheduledDaily();// w w w . j a v a 2 s .c o m route.setDepartureTime(LocalTime.of(9 - i, 30)); route.setArrivalTime(LocalTime.of(14 - i, 0)); routeList.add(route); } }