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 void main(String[] args) {
    LocalDate a = LocalDate.now();

    System.out.println(a);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate l = LocalDate.now();

    System.out.println(l.equals(LocalDate.now()));

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate l = LocalDate.now();

    System.out.println(l);

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate l = LocalDate.now();

    System.out.println(l.hashCode());

}

From source file:Main.java

public static void main(String[] argv) {
    LocalDate today = LocalDate.now();
    LocalDate tomorrow = today.plusDays(1);
    System.out.println(tomorrow.isAfter(today));

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate today = LocalDate.now();

    LocalDate nextYear = today.plusYears(1);

    System.out.println(String.format("Today %s and next year %s", today, nextYear));
}

From source file:Main.java

public static void main(String[] argv) {

    LocalDate date1 = LocalDate.now();
    LocalDate date2 = LocalDate.of(date1.getYear(), date1.getMonth(), date1.getDayOfMonth());
    if (date1.equals(date2)) {
        System.out.printf("Today %s and date1 %s are same date %n", date1, date2);
    }// w  ww . java2 s  .c  o m

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate a = LocalDate.from(LocalDate.now());

    System.out.println(a);
}

From source file:Main.java

public static void main(String[] argv) {
    LocalDate today = LocalDate.now();
    if (today.isLeapYear()) {
        System.out.println("This year is Leap year");
    } else {//from www  . j  av  a 2  s .  c o m
        System.out.println("not a Leap year");
    }

    if (today.withYear(2016).isLeapYear()) {
        System.out.println("2016 is Leap year");
    }

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate today = LocalDate.now();

    // plus and minus operations
    System.out.println("10 days after today will be " + today.plusDays(10));
    System.out.println("3 weeks after today will be " + today.plusWeeks(3));
    System.out.println("20 months after today will be " + today.plusMonths(20));

    System.out.println("10 days before today will be " + today.minusDays(10));
    System.out.println("3 weeks before today will be " + today.minusWeeks(3));
    System.out.println("20 months before today will be " + today.minusMonths(20));

}