Example usage for java.time LocalDate of

List of usage examples for java.time LocalDate of

Introduction

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

Prototype

public static LocalDate of(int year, int month, int dayOfMonth) 

Source Link

Document

Obtains an instance of LocalDate from a year, month and day.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, 6, 21);
    System.out.println(localDate);

    LocalDateTime localTime1 = localDate.atStartOfDay();
    System.out.println(localTime1);

    LocalDateTime localTime2 = localDate.atTime(16, 21);
    System.out.println(localTime2);
}

From source file:Main.java

public static void main(String[] args) {

    LocalDate firstDate = LocalDate.of(2013, 5, 17);
    LocalDate secondDate = LocalDate.of(2015, 3, 7);
    Period period = Period.between(firstDate, secondDate);

    System.out.println(period);/*from   w w  w.jav  a2  s  .  c o  m*/

    int days = period.getDays(); // 18

    int months = period.getMonths(); // 9
    int years = period.getYears(); // 4
    boolean isNegative = period.isNegative(); // false

}

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);
    }//from   w  ww . j  av a 2 s . c  o  m

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, Month.AUGUST, 3);
    System.out.println(localDate);
    Month month1 = Month.from(localDate);
    System.out.println(month1);/*w ww .  j  av a  2 s. com*/

    Month month2 = Month.of(2);
    System.out.println(month2);

    Month month3 = month2.plus(2);
    System.out.println(month3);

    Month month4 = localDate.getMonth();
    System.out.println(month4);

    int monthIntValue = month2.getValue();
    System.out.println(monthIntValue);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, 6, 21);
    System.out.println(localDate);
    DayOfWeek dayOfWeek1 = DayOfWeek.from(localDate);
    System.out.println(dayOfWeek1);
    int intValue = dayOfWeek1.getValue();
    System.out.println(intValue);
    DayOfWeek dayOfWeek2 = localDate.getDayOfWeek();
    System.out.println(dayOfWeek2);
    DayOfWeek dayOfWeekFromInteger = DayOfWeek.of(7);
    System.out.println(dayOfWeekFromInteger);
    DayOfWeek dayOfWeekAdded = dayOfWeekFromInteger.plus(1);
    System.out.println(dayOfWeekAdded);
    DayOfWeek dayOfWeekSubtracted = dayOfWeekFromInteger.minus(2);
    System.out.println(dayOfWeekSubtracted);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate a = LocalDate.of(2014, 6, 30);

    LocalDateTime l = a.atTime(LocalTime.NOON);
    System.out.println(l);/*from  www .  ja  va2 s.c om*/
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, Month.JUNE, 21);
    DayOfWeek dayOfWeek = DayOfWeek.from(localDate);
    System.out.println(dayOfWeek.getValue());
    dayOfWeek = dayOfWeek.minus(2);//from   ww w .  j  a v  a 2  s. c  om
    System.out.println(dayOfWeek.getValue());
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate a = LocalDate.of(2014, 6, 30);
    OffsetDateTime o = a.atTime(OffsetTime.now());

    System.out.println(o);/*from ww  w .j a v  a  2s .c o m*/
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, Month.JUNE, 21);
    DayOfWeek dayOfWeek = DayOfWeek.from(localDate);
    System.out.println(dayOfWeek.getValue());
    dayOfWeek = dayOfWeek.plus(2);//  w w  w  .j  a  v  a  2  s .co m
    System.out.println(dayOfWeek.getValue());
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, Month.JUNE, 21);
    DayOfWeek dayOfWeek = DayOfWeek.from(localDate);
    System.out.println(dayOfWeek.name());
    System.out.println(dayOfWeek.getValue());
    System.out.println(dayOfWeek.ordinal());
}