Example usage for java.time LocalTime now

List of usage examples for java.time LocalTime now

Introduction

In this page you can find the example usage for java.time LocalTime now.

Prototype

public static LocalTime now() 

Source Link

Document

Obtains the current time from the system clock in the default time-zone.

Usage

From source file:agendapoo.View.FrmCadastroAtividade.java

private boolean isOldTime(LocalDate data, LocalTime end) {
    Period p = Period.between(data, LocalDate.now());
    if (p.getDays() > 0)
        return true;
    else if (p.getDays() == 0) {
        return end.isBefore(LocalTime.now());
    }/*from   w ww. j a  v  a 2  s .  c  o m*/
    return false;
}

From source file:alfio.manager.UploadedResourceIntegrationTest.java

@Before
public void ensureConfiguration() {

    IntegrationTestUtil.ensureMinimalConfiguration(configurationRepository);
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null,
            "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now().minusDays(1), LocalTime.now()),
            new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), DESCRIPTION, BigDecimal.TEN,
            false, "", false, null, null, null, null, null));
    Pair<Event, String> eventAndUser = initEvent(categories, organizationRepository, userManager, eventManager,
            eventRepository);/*from w w  w  .ja va2s . com*/

    event = eventAndUser.getKey();
    user = eventAndUser.getValue() + "_owner";
}

From source file:alfio.manager.AdminReservationManagerIntegrationTest.java

@Test
public void testReserveFromExistingCategory() throws Exception {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null,
            "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()),
            new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "",
            false, null, null, null, null, null));
    performExistingCategoryTest(categories, false, Collections.singletonList(1), false, true, 0,
            AVAILABLE_SEATS);/* ww w. ja  v  a  2 s.c  o m*/
}

From source file:electrical_parameters.Admittance.java

public void printAll() {
    System.out.println("Cas generovania");
    System.out.println(LocalTime.now());
    System.out.println("P [km/F]");
    System.out.println(this.P);
    System.out.println("P_red [km/F]");
    System.out.println(this.P_red);

    System.out.println("C [nF/km]");
    printRealMatrix(this.C.scalarMultiply(1e9));
    System.out.println("B [uS/km]");
    printRealMatrix(this.B.scalarMultiply(1e6));
    System.out.println("Y [S/km]");
    printComplexMatrix(this.Y);

    System.out.println("C_Symm [nF/km]");
    printRealMatrix(this.C_symm.scalarMultiply(1e9));
    System.out.println("B_symm [uS/km]");
    printRealMatrix(this.B_symm.scalarMultiply(1e6));
    System.out.println("Y_symm [S/km]");
    printComplexMatrix(this.Y_symm);

}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testUnboundedTicketsGeneration() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null,
            "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()),
            new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "",
            false, null, null, null, null, null));
    Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository)
            .getKey();//  w w w  .j a  v  a 2  s. c o m
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertNotNull(tickets);
    assertFalse(tickets.isEmpty());
    assertEquals(AVAILABLE_SEATS, tickets.size());
    assertTrue(tickets.stream().allMatch(t -> t.getCategoryId() == null));
}

From source file:alfio.manager.TicketReservationManagerIntegrationTest.java

@Test
public void testPriceIsOverridden() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null,
            "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()),
            new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "",
            false, null, null, null, null, null));
    Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository)
            .getKey();//from   w w w .  j  av a 2s  .co m

    TicketReservationModification tr = new TicketReservationModification();
    tr.setAmount(2);
    TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
    tr.setTicketCategoryId(category.getId());
    TicketReservationWithOptionalCodeModification mod = new TicketReservationWithOptionalCodeModification(tr,
            Optional.empty());
    ticketReservationManager.createTicketReservation(event, Collections.singletonList(mod),
            Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(),
            Locale.ENGLISH, false);
    List<Ticket> pendingTickets = ticketRepository
            .findPendingTicketsInCategories(Collections.singletonList(category.getId()));
    assertEquals(2, pendingTickets.size());
    pendingTickets.forEach(t -> assertEquals(1000, t.getFinalPriceCts()));
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertEquals(18, tickets.size());
    assertTrue(tickets.stream().allMatch(t -> t.getCategoryId() == null));
}

From source file:alfio.manager.AdminReservationManagerIntegrationTest.java

@Test
public void testReserveFromExistingMultipleCategories() throws Exception {
    List<TicketCategoryModification> categories = Arrays.asList(
            new TicketCategoryModification(null, "default", 10,
                    new DateTimeModification(LocalDate.now(), LocalTime.now()),
                    new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN,
                    false, "", false, null, null, null, null, null),
            new TicketCategoryModification(null, "2nd", 10,
                    new DateTimeModification(LocalDate.now(), LocalTime.now()),
                    new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN,
                    false, "", false, null, null, null, null, null));
    performExistingCategoryTest(categories, false, Arrays.asList(10, 10), false, true, 0, AVAILABLE_SEATS);
}

From source file:alfio.test.util.IntegrationTestUtil.java

public static Pair<Event, String> initEvent(List<TicketCategoryModification> categories,
        OrganizationRepository organizationRepository, UserManager userManager, EventManager eventManager,
        EventRepository eventRepository) {

    String organizationName = UUID.randomUUID().toString();
    String username = UUID.randomUUID().toString();
    String eventName = UUID.randomUUID().toString();

    userManager.createOrganization(organizationName, "org", "email@example.com");
    Organization organization = organizationRepository.findByName(organizationName).get();
    userManager.insertUser(organization.getId(), username, "test", "test", "test@example.com", Role.OPERATOR,
            User.Type.INTERNAL);
    userManager.insertUser(organization.getId(), username + "_owner", "test", "test", "test@example.com",
            Role.OWNER, User.Type.INTERNAL);

    LocalDateTime expiration = LocalDateTime.now().plusDays(5).plusHours(1);

    Map<String, String> desc = new HashMap<>();
    desc.put("en", "muh description");
    desc.put("it", "muh description");
    desc.put("de", "muh description");

    EventModification em = new EventModification(null, Event.EventType.INTERNAL, "url", "url", "url", "url",
            null, eventName, "event display name", organization.getId(), "muh location", "0.0", "0.0",
            ZoneId.systemDefault().getId(), desc,
            new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()),
            new DateTimeModification(expiration.toLocalDate(), expiration.toLocalTime()), BigDecimal.TEN, "CHF",
            AVAILABLE_SEATS, BigDecimal.ONE, true, Collections.singletonList(PaymentProxy.OFFLINE), categories,
            false, new LocationDescriptor("", "", "", ""), 7, null, null);
    eventManager.createEvent(em);/*from   w w w .  j  a v  a2s  .  c  om*/
    Event event = eventManager.getSingleEvent(eventName, username);
    Assert.assertEquals(AVAILABLE_SEATS, eventRepository.countExistingTickets(event.getId()).intValue());
    return Pair.of(event, username);
}

From source file:alfio.manager.WaitingQueueProcessorIntegrationTest.java

@Test
public void testPreRegistration() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null,
            "default", 10, new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()),
            new DateTimeModification(LocalDate.now().plusDays(2), LocalTime.now()), DESCRIPTION, BigDecimal.TEN,
            false, "", false, null, null, null, null, null));
    Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager,
            eventRepository);/*from   w ww  .  jav a2  s .c  o m*/
    Event event = pair.getKey();
    waitingQueueManager.subscribe(event, new CustomerName("Giuseppe Garibaldi", "Giuseppe", "Garibaldi", event),
            "peppino@garibaldi.com", null, Locale.ENGLISH);
    waitingQueueManager.subscribe(event, new CustomerName("Nino Bixio", "Nino", "Bixio", event),
            "bixio@mille.org", null, Locale.ITALIAN);
    assertTrue(waitingQueueRepository.countWaitingPeople(event.getId()) == 2);

    waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);
    assertEquals(18, ticketRepository.findFreeByEventId(event.getId()).size());

    TicketCategoryModification tcm = new TicketCategoryModification(null, "default", 10,
            new DateTimeModification(LocalDate.now().minusDays(1), LocalTime.now()),
            new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()), DESCRIPTION, BigDecimal.TEN,
            false, "", true, null, null, null, null, null);
    eventManager.insertCategory(event.getId(), tcm, pair.getValue());

    waitingQueueSubscriptionProcessor.distributeAvailableSeats(event);

    List<WaitingQueueSubscription> subscriptions = waitingQueueRepository.loadAll(event.getId());
    assertEquals(2, subscriptions.stream().filter(w -> StringUtils.isNotBlank(w.getReservationId())).count());
    assertTrue(subscriptions.stream()
            .allMatch(w -> w.getStatus().equals(WaitingQueueSubscription.Status.PENDING)));
    assertTrue(subscriptions.stream()
            .allMatch(w -> w.getSubscriptionType().equals(WaitingQueueSubscription.Type.PRE_SALES)));

}

From source file:com.bigdata.etl.util.DwUtil.java

public static void bulkInsert(String tableName, List<Map<String, String>> lst) {

    ResultSet rs = null;/*  w ww .  j a v  a  2 s  . c  o  m*/
    java.sql.Statement stmt = null;

    try (java.sql.Connection conn = DataSource.getConnection()) {
        stmt = conn.createStatement();
        rs = stmt.executeQuery("select top 0 * from " + tableName);
        try (SQLServerBulkCopy bulk = new SQLServerBulkCopy(url + "user=" + user + ";password=" + password)) {
            SQLServerBulkCopyOptions sqlsbc = new SQLServerBulkCopyOptions();
            sqlsbc.setBulkCopyTimeout(60 * 60 * 1000);
            bulk.setBulkCopyOptions(sqlsbc);
            bulk.setDestinationTableName(tableName);
            ResultSetMetaData rsmd = rs.getMetaData();
            if (lst == null) {
                return;
            }
            // System.out.println(LocalTime.now() + " "+Thread.currentThread().getId()+" "+lst.size());
            try (CachedRowSetImpl x = new CachedRowSetImpl()) {
                x.populate(rs);
                for (int k = 0; k < lst.size(); k++) {
                    Map<String, String> map = lst.get(k);
                    x.last();
                    x.moveToInsertRow();
                    for (int i = 1; i <= rsmd.getColumnCount(); i++) {
                        String name = rsmd.getColumnName(i).toUpperCase();
                        int type = rsmd.getColumnType(i);//package java.sql.Type?

                        try {
                            switch (type) {
                            case Types.VARCHAR:
                            case Types.NVARCHAR:
                                int len = rsmd.getColumnDisplaySize(i);
                                String v = map.get(name);
                                if (map.containsKey(name)) {
                                    x.updateString(i, v.length() > len ? v.substring(0, len) : v);
                                } else {
                                    x.updateNull(i);
                                }
                                break;
                            case Types.BIGINT:
                                if (map.containsKey(name) && map.get(name).matches("\\d{1,}")) {
                                    x.updateLong(i, Long.valueOf(map.get(name)));
                                } else {
                                    //   x.updateLong(i, 0);
                                    x.updateNull(i);
                                }
                                break;
                            case Types.FLOAT:
                                if (map.containsKey(name) && map.get(name).matches("([+-]?)\\d*\\.\\d+$")) {
                                    x.updateFloat(i, Float.valueOf(map.get(name)));
                                } else {
                                    x.updateNull(i);

                                }
                                break;
                            case Types.DOUBLE:
                                if (map.containsKey(name) && map.get(name).trim().length() > 0
                                        && StringUtils.isNumeric(map.get(name))) {
                                    x.updateDouble(i, Double.valueOf(map.get(name)));
                                } else {
                                    x.updateNull(i);
                                }
                                break;

                            case Types.INTEGER:
                                if (map.containsKey(name) && map.get(name).matches("\\d{1,}")) {
                                    x.updateInt(i, Integer.valueOf(map.get(name)));
                                } else {
                                    x.updateNull(i);
                                }
                                break;

                            default:
                                throw new RuntimeException("? " + type);
                            }
                            /*
                            if(map.containsKey("SYS_TELECOM"))
                            System.err.println(map.get("SYS_TELECOM"));
                             */
                        } catch (RuntimeException | SQLException e) {
                            Logger.getLogger(DwUtil.class.getName()).log(Level.SEVERE,
                                    "? name=" + name + " v=" + map.get(name), e);
                        }

                    }
                    x.insertRow();
                    x.moveToCurrentRow();
                    //x.acceptChanges();
                }

                long start = System.currentTimeMillis();
                bulk.writeToServer(x);
                long end = System.currentTimeMillis();
                System.out.println(LocalTime.now() + " " + Thread.currentThread().getId() + " "
                        + (end - start) + "ms" + " " + x.size());
            }
        }

    } catch (SQLException e) {
        Logger.getLogger(DwUtil.class.getName()).log(Level.SEVERE, null, e);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (stmt != null) {
                stmt.close();
            }
        } catch (SQLException ex) {
            Logger.getLogger(DwUtil.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}