Example usage for java.time LocalDate now

List of usage examples for java.time LocalDate now

Introduction

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

Prototype

public static LocalDate now() 

Source Link

Document

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

Usage

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();/*www  .jav  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:onl.identitas.identity.ejb.entities.Project.java

public Project() {
    this(null, LocalDate.now());
}

From source file:retsys.client.controller.DeliveryChallanReturnController.java

/**
 * Initializes the controller class.//from  ww w . j av  a  2  s .c  o  m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    dc_date.setValue(LocalDate.now());

    material_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("name"));
    brand_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("brand"));
    model_code.setCellValueFactory(new PropertyValueFactory<DCItem, String>("model"));
    units.setCellValueFactory(new PropertyValueFactory<DCItem, String>("model"));
    quantity.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("quantity"));
    amount.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("amount"));

    dcDetail.getColumns().setAll(material_name, brand_name, model_code, quantity, amount);
    // TODO

    AutoCompletionBinding<Item> bindForTxt_name = TextFields.bindAutoCompletion(txt_name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Item>>() {

                @Override
                public Collection<Item> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Item> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("items", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Item>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Item>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Item>() {

                @Override
                public String toString(Item object) {
                    System.out.println("here..." + object);
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Item fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });
    //event handler for setting other item fields with values from selected Item object
    //fires after autocompletion
    bindForTxt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Item>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Item> event) {
            Item item = event.getCompletion();
            //fill other item related fields
            txt_name.setUserData(item.getId());
            txt_brand.setText(item.getBrand());
            txt_model.setText(null); // item doesn't have this field. add??
            txt_rate.setText(String.valueOf(item.getRate()));
        }
    });

    AutoCompletionBinding<DeliveryChallan> bindForProject = TextFields.bindAutoCompletion(project,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<DeliveryChallan>>() {

                @Override
                public Collection<DeliveryChallan> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<DeliveryChallan> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("deliverychallans", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<DeliveryChallan>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<DeliveryChallan>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<DeliveryChallan>() {

                @Override
                public String toString(DeliveryChallan object) {
                    System.out.println("here..." + object);

                    String strDate = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).format(LocalDateTime
                            .ofInstant(object.getChallanDate().toInstant(), ZoneId.systemDefault()));
                    return "Project:" + object.getProject().getName() + " DC Date:" + strDate + " DC No.:"
                            + object.getId();
                }

                @Override
                public DeliveryChallan fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });

    bindForProject
            .setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<DeliveryChallan>>() {

                @Override
                public void handle(AutoCompletionBinding.AutoCompletionEvent<DeliveryChallan> event) {
                    DeliveryChallan dc = event.getCompletion();
                    dc_no.setText(dc.getId().toString());
                    dc_date.setValue(LocalDateTime
                            .ofInstant(dc.getChallanDate().toInstant(), ZoneId.systemDefault()).toLocalDate());
                    dc_no.setText(dc.getId().toString());
                    project.setText(dc.getProject().getName() + " (ID:" + dc.getProject().getId() + ")");
                    deliverymode.setText(dc.getDeliveryMode());
                    concernperson.setText(dc.getConcernPerson());

                    ObservableList<DCItem> items = FXCollections.observableArrayList();
                    Iterator detailsIt = dc.getDeliveryChallanDetail().iterator();
                    while (detailsIt.hasNext()) {
                        DeliveryChallanDetail detail = (DeliveryChallanDetail) detailsIt.next();
                        Item item = detail.getItem();
                        int id = item.getId();
                        String site = item.getSite();
                        String name = item.getName();
                        String brand = item.getBrand();
                        String model = null;
                        int rate = item.getRate().intValue();
                        int quantity = detail.getQuantity();
                        int amount = detail.getAmount();
                        String units = detail.getUnits();

                        items.add(new DCItem(id, name + " (ID:" + id + ")", brand, model, rate, quantity, units,
                                amount));
                    }
                    dcDetail.setItems(items);

                    populateAuditValues(dc);

                }
            });

    txt_qty.focusedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (!newValue) {
                calcAmount();
            }
        }
    });
}

From source file:org.bedework.synch.cnctrs.orgSyncV2.OrgSyncV2ConnectorInstance.java

@Override
public URI getUri() throws SynchException {
    try {/*from w ww. j a  v a 2  s. c om*/
        //Get yesterdays date
        final LocalDate yesterday = LocalDate.now().minus(1, ChronoUnit.DAYS);
        final String yesterdayStr = yesterday.format(DateTimeFormatter.ISO_LOCAL_DATE);

        final URI infoUri = new URI(info.getUri());
        return new URIBuilder().setScheme(infoUri.getScheme()).setHost(infoUri.getHost())
                .setPort(infoUri.getPort()).setPath(infoUri.getPath())
                .setParameter("key", cnctr.getSyncher().decrypt(info.getPassword()))
                .setParameter("start_date", yesterdayStr).build();
    } catch (final SynchException se) {
        throw se;
    } catch (final Throwable t) {
        throw new SynchException(t);
    }
}

From source file:onl.identitas.identity.ejb.entities.Project.java

public Project(String name) {
    this(name, LocalDate.now());
}

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   www .j  a va  2 s.c o  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:onl.identitas.identity.ejb.entities.Story.java

public Story(String name) {
    this.name = name;
    this.startDate = LocalDate.now();
}

From source file:bzzAgent.BiteSizedBzzDaoJpa.java

@Override
public boolean memberHasBSBActivities(String username) {
    Validate.notBlank(username, "username was missing");
    Instant cutoff = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant();

    final StringBuilder sql = new StringBuilder("from BsbAgentActivityEntity bsbaae ")
            .append(" left join fetch bsbaae.incentives incentive ")
            .append(" where bsbaae.username = :username ").append(" and bsbaae.campaignInviteStatus in (1,2)") //'New', 'Viewed'
            .append(" and bsbaae.startDate < '" + cutoff + "' and bsbaae.endDate > '" + cutoff + "'");

    final TypedQuery<BsbAgentActivityEntity> query2 = em
            .createQuery(sql.toString(), BsbAgentActivityEntity.class).setParameter("username", username);

    return BzzUtil.isNotEmpty(query2.getResultList());
}

From source file:com.thesoftwareguild.capstoneblog.controller.HomeController.java

@RequestMapping(value = "/approve-post/{id}", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.NO_CONTENT)//from w  ww  .j  a  v a2 s  . c  o  m
public void approvePost(@PathVariable("id") int id) {

    Post p = dao.getPostById(id);

    // set post status to 'PUBLISHED' and date posted to current time
    p.setStatus(PostStatus.PUBLISHED);
    p.setDatePosted(LocalDate.now());

    dao.updatePost(p);
}