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(2013, 11, 12);
    LocalTime localTime = LocalTime.of(23, 10, 44, 12882);
    ZoneId chicago = ZoneId.of("America/Chicago");
    ZonedDateTime chicagoTime = ZonedDateTime.of(localDate, localTime, chicago);
    System.out.println(chicagoTime);
}

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.isSupported(ChronoField.DAY_OF_YEAR));
}

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.getLong(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);

    Temporal i = dayOfWeek.adjustInto(LocalDate.of(2014, Month.MAY, 22));
    System.out.println(i);//from   w  ww .  ja  va2 s. c  o  m

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate ld1 = LocalDate.of(2014, Month.MAY, 21);
    System.out.println(ld1);/*  ww w.java2s.c  o  m*/
    LocalDate ld2 = ld1.with(TemporalAdjusters.dayOfWeekInMonth(5, DayOfWeek.SUNDAY));
    System.out.println(ld2);
}

From source file:Main.java

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

    // next Sunday (2014-03-02)
    LocalDate nextSunday = date.with(TemporalAdjusters.next(DayOfWeek.SUNDAY));

    System.out.println(nextSunday);
}

From source file:Main.java

public static void main(String[] argv) {
    LocalDate today = LocalDate.now();
    LocalDate java8Release = LocalDate.of(2014, Month.MARCH, 14);
    Period period = Period.between(java8Release, today);
    System.out.println("Period between today and Java 8 release : " + period);
    System.out.println("Period between Java 8 release and today : " + Period.between(today, java8Release));

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate ld1 = LocalDate.of(2014, Month.JANUARY, 7);
    LocalDate ld2 = LocalDate.of(2014, Month.MAY, 21);
    long days = ChronoUnit.DAYS.between(ld1, ld2);
    System.out.println(days);//from   w w  w  .  j  av  a2  s  .c  o m

    LocalTime lt1 = LocalTime.of(6, 0);
    LocalTime lt2 = LocalTime.of(9, 30);
    long hours = ChronoUnit.HOURS.between(lt1, lt2);
    System.out.println(hours);
    long minutes = ChronoUnit.MINUTES.between(lt1, lt2);
    System.out.println(minutes);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate ld1 = LocalDate.of(2014, Month.JANUARY, 7);
    LocalDate ld2 = LocalDate.of(2014, Month.MAY, 18);

    LocalTime lt1 = LocalTime.of(7, 0);
    LocalTime lt2 = LocalTime.of(9, 30);

    long days = ld1.until(ld2, ChronoUnit.DAYS);
    System.out.println(days);//from w ww. java  2s  .  c om
    long hours = lt1.until(lt2, ChronoUnit.HOURS);
    System.out.println(hours);
    long minutes = lt1.until(lt2, ChronoUnit.MINUTES);
    System.out.println(minutes);
}

From source file:Main.java

public static void main(String[] args) {
    Period twoMonthsAndFiveDays = Period.ofMonths(2).plusDays(5);
    LocalDate sixthOfJanuary = LocalDate.of(2014, 1, 6);

    LocalDate eleventhOfMarch = sixthOfJanuary.plus(twoMonthsAndFiveDays);

    System.out.println(eleventhOfMarch);
}