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:Main.java

public static Date toDate(LocalTime localTime) {
    Instant instant = localTime.atDate(LocalDate.now()).atZone(ZoneId.systemDefault()).toInstant();
    return toDate(instant);
}

From source file:Main.java

public static LocalDate[] getWeekday(LocalDate date) {
    int DAYS_OF_WEEK = 7;

    if (date == null) {
        date = LocalDate.now();
    }/*  ww w . j  av a2  s .c  om*/

    LocalDate begin = null;
    if (date.getDayOfWeek().equals(DayOfWeek.SUNDAY)) {
        begin = date;
    } else {
        begin = date.minusDays(date.getDayOfWeek().getValue());
    }
    LocalDate end = begin.plusDays(DAYS_OF_WEEK - 1);

    LocalDate localDate[] = { begin, end };

    return localDate;

}

From source file:Main.java

public static Period period(LocalDate hiringDate) {
    LocalDate today = LocalDate.now();
    return Period.between(hiringDate, today);
}

From source file:Main.java

public static List<LocalDate> getDatesFrom(Date startDate) {
    List<LocalDate> dates = new ArrayList<>();

    LocalDate startLocalDate = getLocalDateFromDate(startDate);

    LocalDate endLocalDate = LocalDate.now();

    dates.add(startLocalDate);//from www.j av a 2  s  .  c o m
    for (int i = 0; i < ChronoUnit.DAYS.between(startLocalDate, endLocalDate); i++) {
        dates.add(startLocalDate.plusDays(i + 1));
    }

    return dates;
}

From source file:mesclasses.util.FileSaveUtil.java

public static File archive() throws IOException {

    FileConfigurationManager conf = FileConfigurationManager.getInstance();

    File archiveFile = new File(
            new StringBuilder(conf.getArchivesDir()).append(File.separator).append("mesclasses_archive_")
                    .append(LocalDate.now().format(Constants.DATE_FORMATTER)).append(".zip").toString());
    if (archiveFile.exists()) {
        archiveFile.delete();//from w w w . jav  a2 s  . c  om
    }
    ZipUtil.pack(new File(conf.getSaveDir()), archiveFile);
    LOG.info("Archive cre : " + archiveFile.getPath());
    return archiveFile;
}

From source file:org.sakuli.starter.helper.CmdPrintHelper.java

private static void printSakuliHeader() {
    System.out.println("\n" + "Sakuli JAR starter:\n" + LocalDate.now().getYear() + " - The Sakuli team.\n"
            + "http://www.sakuli.org\n" + "https://github.com/ConSol/sakuli\n");
}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox vbox = new VBox(20);
    Scene scene = new Scene(vbox, 400, 400);
    stage.setScene(scene);/*from w  ww.  j a  v  a2  s  .c  o m*/
    DatePicker startDatePicker = new DatePicker();
    DatePicker endDatePicker = new DatePicker();

    startDatePicker.setValue(LocalDate.now());
    endDatePicker.setValue(startDatePicker.getValue().plusDays(1));

    vbox.getChildren().add(new Label("Start Date:"));
    vbox.getChildren().add(startDatePicker);
    vbox.getChildren().add(new Label("End Date:"));
    vbox.getChildren().add(endDatePicker);
    stage.show();
}

From source file:dijalmasilva.core.service.VisitaServiceImpl.java

@Override
public List<Visita> visitasDeHoje(Long id) {
    return dao.findDistinctByVisitadoAndData(id, LocalDate.now());
}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox vbox = new VBox(20);
    Scene scene = new Scene(vbox, 400, 400);
    stage.setScene(scene);// w  w w .j ava2s.c  om
    DatePicker startDatePicker = new DatePicker();
    DatePicker endDatePicker = new DatePicker();
    startDatePicker.setValue(LocalDate.now());
    final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() {
        @Override
        public DateCell call(final DatePicker datePicker) {
            return new DateCell() {
                @Override
                public void updateItem(LocalDate item, boolean empty) {
                    super.updateItem(item, empty);

                    if (item.isBefore(startDatePicker.getValue().plusDays(1))) {
                        setDisable(true);
                        setStyle("-fx-background-color: #EEEEEE;");
                    }
                }
            };
        }
    };
    endDatePicker.setDayCellFactory(dayCellFactory);
    endDatePicker.setValue(startDatePicker.getValue().plusDays(1));
    vbox.getChildren().add(new Label("Start Date:"));
    vbox.getChildren().add(startDatePicker);
    vbox.getChildren().add(new Label("End Date:"));
    vbox.getChildren().add(endDatePicker);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox vbox = new VBox(20);
    Scene scene = new Scene(vbox, 400, 400);
    stage.setScene(scene);/*from  ww  w.  ja  va  2s  .c  o m*/
    final DatePicker startDatePicker = new DatePicker();
    DatePicker endDatePicker = new DatePicker();
    startDatePicker.setValue(LocalDate.now());
    final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() {
        @Override
        public DateCell call(final DatePicker datePicker) {
            return new DateCell() {
                @Override
                public void updateItem(LocalDate item, boolean empty) {
                    super.updateItem(item, empty);

                    long p = ChronoUnit.DAYS.between(startDatePicker.getValue(), item);
                    setTooltip(new Tooltip("You're about to stay for " + p + " days"));
                }
            };
        }
    };
    endDatePicker.setDayCellFactory(dayCellFactory);
    endDatePicker.setValue(startDatePicker.getValue().plusDays(1));
    vbox.getChildren().add(new Label("Start Date:"));
    vbox.getChildren().add(startDatePicker);
    vbox.getChildren().add(new Label("End Date:"));
    vbox.getChildren().add(endDatePicker);
    stage.show();
}