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 independenceDay = LocalDate.of(2014, Month.JULY, 4);
    DayOfWeek dayOfWeek = independenceDay.getDayOfWeek();
    System.out.println(dayOfWeek); // FRIDAY

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate date = LocalDate.of(2014, Month.FEBRUARY, 25); // 2014-02-25

    // last day of February 2014 (2014-02-28)
    LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
    System.out.println(lastDayOfMonth);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate ld = LocalDate.of(2014, Month.JANUARY, 1);
    String pattern = "'New Year in'  yyyy  'is on' EEEE";
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
    String str = ld.format(formatter);
    System.out.println(str);/* w w w. j a  va  2 s. c o m*/

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate date = LocalDate.of(2014, Month.FEBRUARY, 25); // 2014-02-25

    // first day of February 2014 (2014-02-01)
    LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth());

    System.out.println(firstDayOfMonth);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate date = LocalDate.of(2014, Month.FEBRUARY, 25); // 2014-02-25

    // last day of 2014 (2014-12-31)
    LocalDate lastDayOfYear = date.with(TemporalAdjusters.lastDayOfYear());

    System.out.println(lastDayOfYear);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate date = LocalDate.of(2014, Month.FEBRUARY, 25); // 2014-02-25

    // first day of next month (2014-03-01)
    LocalDate firstDayOfNextMonth = date.with(TemporalAdjusters.firstDayOfNextMonth());

    System.out.println(firstDayOfNextMonth);
}

From source file:Main.java

public static void main(String[] args) {
    Period employmentPeriod = period(LocalDate.of(2000, Month.FEBRUARY, 1));
    int years = employmentPeriod.getYears();
    int months = employmentPeriod.getMonths();
    int days = employmentPeriod.getDays();

    System.out.println(years);/* w  w w .j av a2  s  .  c om*/
    System.out.println(months);
    System.out.println(days);
}

From source file:Main.java

public static void main(String[] args) {

    LocalDate startEmployment = LocalDate.of(2011, Month.FEBRUARY, 1);

    LocalDate today = LocalDate.now();

    long numberOfDays = startEmployment.until(today, ChronoUnit.DAYS);

    System.out.println(String.format("%d", numberOfDays));

}

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.get(ChronoField.DAY_OF_WEEK));
}

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.range(ChronoField.DAY_OF_WEEK));
}